Because nobody else would type 30000 lines rather than 10. :)
You enter 33 into the textbox, which IS greater than 32, so you get the message. That is what you wanted?Code:If Val(Options1.Textbox.Text) >= 32 Then
Testbox.ShowDialog()
End If
Printable View
Because nobody else would type 30000 lines rather than 10. :)
You enter 33 into the textbox, which IS greater than 32, so you get the message. That is what you wanted?Code:If Val(Options1.Textbox.Text) >= 32 Then
Testbox.ShowDialog()
End If
Yes but the main problem is when I type 33 on the textbox, it should be displaying the messagebox but I have received an error:
Value of '65' is not valid for 'Value'. 'Value' should be between 'Minimum' and 'Maximum'.
The maximum number is only 32 for trackbar, I wanted the textbox to check if I go over the limit numbers of value on trackbar and display straight away if I go over the limit numbers??
Hope you can help.
Thanks,
Mark
Did you mark the textbox to be VALIDATE(d)? It won't let you exit with the wrong numbers? That's where you need to change the message, if you don't like it.
Usually validation is all that's required. They won't be able to enter anything higher than Maximum
No I haven't, so how I can change the textbox to be validate??
Thanks,
Mark
search for that exact error message to find where it's being called.
where did you get the textbox code? it must have a validate event somewhere.
again, search for it.
Free trial at Experts-Exchange
https://secure.experts-exchange.com/...RL=%2F&cid=576
Can you explain what it is your module is meant to be doing (one paragraph will be fine, not 35,000)? If we could understand what you were doing then we can better understand how to help you and reduce the size of that horrendous chunk of code you have there and maybe even teach your a few coding best practices along the way. ;)
@Oblio: Will you please stop posting any spams that I have received from you. Read the forum rules and if you continue to spam then you will be banned. Just post the info to this forum which it much welcome. Simple as that.
@visualAd: Well on my method they are doing to move the value from 0 to 32 when I type on the textbox so from 33 to any of the highest value I wanted to receive the messagebox when I type the high numbers on the textbox but I have received an error for the same reasons. I tried to use this code but it didn't solve it correctly
Code:If Val(Form2.Textbox.Text = "32") <= 31 Then
Form2.TrackBar2.Value = Val(Form2.Textbox.Text)
ElseIf Val(Form2.Textbox.Text = "33") >= 32 Then
Testbox.ShowDialog()
End If
I know that the trackbar2 has maximum number up to 32 but I would be happy to ignore the code for controlling when I type the highest value just after 32. Hope you guys can help me out and get this problem right away.
Thanks,
Mark
Anyone who uses the Val function needs to be shot. Use the Integer.Parse / Float.Parse functions.Quote:
Originally Posted by mark103
Now after reading your previous post it looks like you are still describing the problem. We know that you have a problem, however, in order to help you solve the problem we need to understand what you are trying to achieve. Forget about the code you have posted so far (delete it for all I care - just don't post it again :D) and tell us what the code is doing. Even better, if it is related to a real world scenario tell us what it is because there is probably already an algorithm out there that works well and even if there is not it will help us to understand.
Leave the hiring and firing to HR and just concentrate on not getting banned from this forum too ;)Quote:
Originally Posted by mark103
That's a little harsh. Yes VAL is a vb6 function but it still works in .NET. And yes he should use the .parse or possibly ctype. No need to be rude about it.Quote:
Originally Posted by visualAd
In this code...
...I don't think it is doing what you think it is. And I am not sure how the VAL function would do this, however, I think it would be parsed like this.Code:If Val(Form2.Textbox.Text = "32") <= 31 Then
Form2.TrackBar2.Value = Val(Form2.Textbox.Text)
ElseIf Val(Form2.Textbox.Text = "33") >= 32 Then
Testbox.ShowDialog()
End If
Does " Form2.Textbox.Text = "32" " If the answer is yes, take the val of true which would equal 1. If no, take the val of false which should be 0. Either case would then be less than or equal to 31 and you will always try to set the value of the trackbar to whatever the value is in form2.textbox.text. I think what you are looking for is something like this.
Code:If CType(Form2.Textbox.Text, Integer) <= 31 Then
Form2.TrackBar2.Value = CType(Form2.Textbox.Text,Integer)
Else
Testbox.ShowDialog()
End If
Sorry, I should have added a face to the end of that. Yes Val is in VB6 however I would generally stay away from it then, unless you generally do not know the data type of the data which will be entered.Quote:
Originally Posted by sotoasty
Anyhow rest assured I did not intend to be rude. May be I should rephrase "using VAL is shooting yourself in the foot" ;) :wave:
@mark, please don't tell me what to do. i posted those links so people would see what they are dealing with. i don't mean this in a mean way, but you need an intro to visual basic programming class.Code:Dim tbVAL As Integer = 0
If Integer.TryParse(TextBox1.Text, tbVAL) Then
If tbVAL >= 0 AndAlso tbVAL <= 32 Then TrackBar1.Value = tbVAL Else TrackBar1.Value = TrackBar1.Maximum
Else
MessageBox.Show("Numbers Only Please")
End If
e.g. What do you think this means
If Val(Form2.Textbox.Text = "32") <= 31
Did you understand the explanation?
@sotoasty - in one thread at MSDN mark103 told someone they were a f'ing c*nt. i am beginning to believe this is a joke.
Oblio - turn on your PM's