Page 1 of 1

VB help

Posted: Tue Oct 27, 2009 6:15 pm
by Liidian
Why doesn't this work?.

Private Sub Text1_Change()
IF (Message153.text = "Lol") THEN
MsgBox "Wow"
ElSEIF (Message153.text = "wow")
MsgBox "lol"
END IF
END Sub

Re: VB help

Posted: Tue Oct 27, 2009 9:20 pm
by plope0726
Liidian wrote:Why doesn't this work?.

Private Sub Text1_Change()
IF (Message153.text = "Lol") THEN
MsgBox "Wow"
ElSEIF (Message153.text = "wow")
MsgBox "lol"
END IF
END Sub
is this the entire code? If so then you haven't declared the variable Message153.text. You need to give the variable a value before you can run a test on it like this. Try adding "Dim Message153.text as string = "Lol" before the If statement. And I may be wrong but i think you need to type MessageBox.show() not MsgBox

Private Sub Text1_Change()

Dim Message153.text as string = "Lol"

IF (Message153.text = "Lol") THEN
MessageBox.show("Wow")
ElSEIF (Message153.text = "wow")
MessageBox.show("lol")
END IF
END Sub

Re: VB help

Posted: Tue Oct 27, 2009 9:49 pm
by Liidian
plope0726 wrote:
Liidian wrote:Why doesn't this work?.

Private Sub Text1_Change()
IF (Message153.text = "Lol") THEN
MsgBox "Wow"
ElSEIF (Message153.text = "wow")
MsgBox "lol"
END IF
END Sub
is this the entire code? If so then you haven't declared the variable Message153.text. You need to give the variable a value before you can run a test on it like this. Try adding "Dim Message153.text as string = "Lol" before the If statement. And I may be wrong but i think you need to type MessageBox.show() not MsgBox

Private Sub Text1_Change()

Dim Message153.text as string = "Lol"

IF (Message153.text = "Lol") THEN
MessageBox.show("Wow")
ElSEIF (Message153.text = "wow")
MessageBox.show("lol")
END IF
END Sub
KK Thanks ^^

Posted: Wed Oct 28, 2009 3:47 am
by PaRaDoX
Don't you need to start (and end) a class as well? (Or something to that effect, trying to remember)

Posted: Wed Oct 28, 2009 3:52 am
by plope0726
yeah but I think that in VB the private sub / end sub is the start and end of the class.

Posted: Wed Oct 28, 2009 10:11 pm
by PaRaDoX
Although its kinda 'cheating', you can try running that in VBExpress, it should tell you whats wrong with it.