all groups > dotnet academic > april 2006 >
You're in the

dotnet academic

group:

Debugging Errors


Debugging Errors Merlyn-12
4/2/2006 11:29:03 PM
dotnet academic: I have installed Visual Studio 2003 on a laptop that has XP Home as the
opperating system. There were no error messages when I installed. I have
tried to write my first program in VB. I am using the LEFT function to give
me the first 5 characters in a text box. The basic statement is a follows.
strTemp = Left(strText1, 5)
Where strTemp and strText1 are string variables
When I run it gives me an error saying that the Left() only excepts integers.
If I tell it to ignore the error and continue, it evaluates the statement
properly.
Later in the same code I have an if statement.
IF strText2 = "Now" then
and not mater what is in strText2, the statement evaluates to TRUE.
These 2 problems have me concerned about the installation of Visual Studio.
Re: Debugging Errors pvdg42
4/3/2006 6:51:54 AM

[quoted text, click to view]

I don't think there is anything wrong with your installation. Try code like
this to use the Left() function:

Dim s As String

s = Microsoft.VisualBasic.Left(TextBox1.Text, 5)

If s = "12345" Then

Label1.Text = "67890"

Else

Label1.Text = "00000"

End If

The code above works fine here.

You might also consider looking through the help at the various methods
available to you in the .NET String class for text handling.



Re: Debugging Errors Homer J Simpson
4/12/2006 9:41:42 PM

[quoted text, click to view]

Can you provide a LITTLE more code?
Try:-


Imports Microsoft.VisualBasic

Dim strText1 As String = "TestLine"
Dim strTemp As String, strText2 As String
If Len(strText1) > 4 Then
strTemp = Microsoft.VisualBasic.Left(strText1, 5)
End If
strText2 = "Then"
If strText2 = "Now" Then strText2 = "OK!"

Re: Debugging Errors Homer J Simpson
4/12/2006 11:50:02 PM

[quoted text, click to view]

Found the problem. 'Left' is a function used in WinForms. You need to use

Microsoft.VisualBasic.Left

to disambiguate it and make it work.


AddThis Social Bookmark Button