Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 What am i doing Wrong??
Index -> Programming, Visual Basic and Other Basics -> Visual Basic Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Anya




PostPosted: Sat Jun 17, 2006 6:24 pm   Post subject: What am i doing Wrong??

The following is the code I have for error checking within my subprogram,

If txtName.Text = "" Then MsgBox "Name not Entered", vbOkOnly, "DAte Input Error"
ElseIf Not IsNumeric (txtSilver.Text) Then MsgBox "Not a Number",
vbOkOnly, "Data Input Error"

my problem here is when I run the program im given an error message that says Else without If. and then directs me to the ElseIf statement. I dont know whats wrong, can anyone help ???? Laughing
Sponsor
Sponsor
Sponsor
sponsor
wtd




PostPosted: Sat Jun 17, 2006 6:50 pm   Post subject: (No subject)

Use code tags, and skip to a newline after "then".
Anya




PostPosted: Sat Jun 17, 2006 6:54 pm   Post subject: (No subject)

i do have a new line after then in my actual program... and what do you mean by code tags, i thought i was
wtd




PostPosted: Sat Jun 17, 2006 7:01 pm   Post subject: (No subject)

code:
[code][/code]
GlobeTrotter




PostPosted: Sat Jun 17, 2006 8:27 pm   Post subject: (No subject)

Also, it is proper formatting to use parenthesis when calling a function. eg: instead of
code:

MsgBox "Hello"


use

code:

Call MsgBox ("Hello")
Anya




PostPosted: Sat Jun 17, 2006 8:46 pm   Post subject: (No subject)

I know that but they arent necessary for it to work.. i just want it to work... i still keep getting and erroe message that saya Else without If.. and sends me back to the ElseIf ... i cant see the problem
GlobeTrotter




PostPosted: Sat Jun 17, 2006 9:18 pm   Post subject: (No subject)

This should work, if not post the exact code causing the problems.

code:

If txtName.Text = "" Then
    Call MsgBox ("Name not Entered", vbOkOnly, "Data Input Error")
ElseIf Not IsNumeric (txtSilver.Text) Then
    Call MsgBox ("Not a Number", vbOkOnly, "Data Input Error")
End If
cool dude




PostPosted: Sun Jun 18, 2006 10:38 am   Post subject: (No subject)

Anya wrote:
i do have a new line after then in my actual program... and what do you mean by code tags, i thought i was


thats a lie! the reason i know is because that is the exact error your getting because your not skipping a line. btw u r missing an end if at the end of your code.
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, Visual Basic and Other Basics -> Visual Basic Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 8 Posts ]
Jump to:   


Style:  
Search: