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.
Any sugestions on where to look for a salution.
pvdg42 - 03 Apr 2006 12:51 GMT
>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
[quoted text clipped - 14 lines]
> Studio.
> Any sugestions on where to look for a salution.
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.
Homer J Simpson - 12 Apr 2006 22:41 GMT
> 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
[quoted text clipped - 14 lines]
> Studio.
> Any sugestions on where to look for a salution.
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!"
Homer J Simpson - 13 Apr 2006 00:50 GMT
> 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
[quoted text clipped - 6 lines]
> When I run it gives me an error saying that the Left() only excepts
> integers.
Found the problem. 'Left' is a function used in WinForms. You need to use
Microsoft.VisualBasic.Left
to disambiguate it and make it work.