error: End of statement expected

Tom3885

Member
Joined
Sep 23, 2006
Messages
5
Programming Experience
Beginner
Hi,
I'm just starting out on VB.net 2003 and attend Devry in my first year. I hope everyone can be patient with me as I said before I'm really new at this.

I'm doing a lab this week and have a question on declaring variables. This is what I have so far:

I need to be able to input a number in a textbox from 101-500 and if the number is in that range then it has to display in the textbox on the form. If not then I have to display a message like "number too small, try again"

Our textbook that we're using doesn't explain things very well so that's why I'm here seeking help.

This is how I declared the variable:
Dim TextBox1_Input AsInteger

In the stub for the tex box I have:

If (TextBox1_Input>= 500)else [(TextBox1_Input <=101)]
EndIf


When I try to test the program I get a pop up that says "build errors" and on the bottom it has "End of statement expected"
I can't figure out what the end of statement is supposed to be. I thought an end of statement was end if?

thank you to anyone who can help me through this.
Tom

You'll probably see alot of me over the next 8 weeks.
Can someone tell me what I'm doing wrong?
 
try this:
If the text input is greater than 100 and less than 501 then display number
else if it is less than 101 then display message "number too small" and if it is over 501 then display "too large".
hope this help!
 
this is the format:
VB.NET:
If (condition) Then

Else 'Optional

End If

so here's a start:
VB.NET:
If [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#000000]TextBox1_Input > 500 Then
  'It's too large
Else
  'Display in textbox
End If
[/COLOR][/SIZE][/COLOR][/SIZE]
 
I assume you will have a textbox and a enter button.. place the text box on the screen and a button, the default name for these it textbox1 and button1, then double click on the button1 and it will open up the sub for clicking on it.

then I would do something like..

If int(textbox1.text) > 500 Then msgbox "Your number is to big"
If int(textbox1.text) < 100 Then msgbox "Your number is to small"
If int(textbox1.text) > 99 AND int(textbox1.text) < 501 Then msgbox "Bingo"

you also might need to build in some error handling incase they enter 'abc'

hope this helps..

Steve
 
sorry forgot the ().. only just moving over from VB myself and slight things are different.. below is the full sub. the above sample didnt use variables as you dont need to really, but if your project needs them then something like this will do..

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim textinput As Integer

On Error GoTo errorhandler

textinput = TextBox1.Text
If textinput > 500 Then MsgBox("Your number is to big")
If textinput < 101 Then MsgBox("Your number is to small")
If textinput > 100 And textinput < 501 Then MsgBox("Bingo")
TextBox1.Text = ""
Exit Sub

errorhandler:

MsgBox("Please enter a number between 101 and 500")
TextBox1.Text = ""

End Sub


cheers

Steve
 
wouldnt this be a bit easier?
VB.NET:
If IsNumeric(TextBox1.Text) = True Then
    If Cint(TextBox1.Text) >= 500 OrElse CInt(TextBox1.Text) <= 100 Then
        MessageBox.Show("Please enter a number between 100 and 500")
    Else
        'Number was correct
    End If
Else
    MessageBox.Show("Please enter a number")
End If
 
thanks for the help!

to everyone that helped!

thanks because of the help I got the idea and applied it to my lab.

tom
 
Back
Top