HighTechTalks DotNet Forums  

Debugging Errors

Dotnet Academic General Discussions microsoft.public.dotnet.academic


Discuss Debugging Errors in the Dotnet Academic General Discussions forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Merlyn-12
 
Posts: n/a

Default Debugging Errors - 04-03-2006 , 02:29 AM






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.

Reply With Quote
  #2  
Old   
pvdg42
 
Posts: n/a

Default Re: Debugging Errors - 04-03-2006 , 07:51 AM







"Merlyn-12" <Merlyn-12 (AT) discussions (DOT) microsoft.com> wrote

Quote:
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.
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.






Reply With Quote
  #3  
Old   
Homer J Simpson
 
Posts: n/a

Default Re: Debugging Errors - 04-12-2006 , 05:41 PM




"Merlyn-12" <Merlyn-12 (AT) discussions (DOT) microsoft.com> wrote

Quote:
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.
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!"




Reply With Quote
  #4  
Old   
Homer J Simpson
 
Posts: n/a

Default Re: Debugging Errors - 04-12-2006 , 07:50 PM




"Merlyn-12" <Merlyn-12 (AT) discussions (DOT) microsoft.com> wrote

Quote:
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.
Found the problem. 'Left' is a function used in WinForms. You need to use

Microsoft.VisualBasic.Left

to disambiguate it and make it work.





Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.