Click here to Skip to main content
15,665,480 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
OK, I have a code here:

If TextBox1.Text = Label1.Text Then
        End If

And lets say label1.text says 87, how would I make it to where the message would still pop up if the text in textbox1 said 86 or 88?
Updated 25-Aug-10 16:14pm
Christian Graus 25-Aug-10 21:45pm    
Reason for my vote of 1
Wrong tag, asking the same question for the third time, has been answered already. OP should have edited his original question, or at least posted some code to show that he'd tried to do this task, given how trivial it is, and that he's already been told how to do it.
Smithers-Jones 26-Aug-10 7:26am    
Reason for my vote of 1

You have been asking this for days. I know I told you the answer already. Why are you asking it again ?
Share this answer
jerryg225 25-Aug-10 22:03pm    
Actually I asked this morning, and I never got an answer. D:

If you gave me the answer already, tell me again?
Smithers-Jones 26-Aug-10 7:26am    
"If you gave me the answer already, tell me again?" - How about going back to one of the versions of your question, where you can read the answer yourself?
To reiterate my answer:

What you want to do, is to store your time as a DateTime, then try to convert the text in the textbox to a datetime. Then you can use comparison operators to see how close the user was, and decide your margin for letting them win, and tell them if they are higher than lower. I'm not sure how this is going to be great fun, but it's certainly a valid exercise if you're teaching yourself VB.

I am not sure if there's a DateTime.TryParse, or a Convert.ToDateTime. Be sure to make sure your code handles if the person has typed in a non datetime. Worse case, you can use the methods on the string class, or a regex, to split your string into numbers, and then use int.Parse to get numbers you can pass to a DateTime constructor.

Because you've moved to comparing an int, you want int.TryParse, but the rest is exactly the same. Turn your text into an int and the comparison operators will work for you to check if a value is within a range
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900