Computer Science Canada

What am i doing Wrong??

Author:  Anya [ 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

Author:  wtd [ Sat Jun 17, 2006 6:50 pm ]
Post subject: 

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

Author:  Anya [ Sat Jun 17, 2006 6:54 pm ]
Post 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

Author:  wtd [ Sat Jun 17, 2006 7:01 pm ]
Post subject: 

code:
[code][/code]

Author:  GlobeTrotter [ Sat Jun 17, 2006 8:27 pm ]
Post subject: 

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

MsgBox "Hello"


use

code:

Call MsgBox ("Hello")

Author:  Anya [ Sat Jun 17, 2006 8:46 pm ]
Post 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

Author:  GlobeTrotter [ Sat Jun 17, 2006 9:18 pm ]
Post 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

Author:  cool dude [ Sun Jun 18, 2006 10:38 am ]
Post 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.


: