Strange behavior with text box values . . . help!

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a strange problem with code that I am running with numerics that I am
puting into text boxes.

I have made a user form that asks my unit supervisors to input two numbers
into two different text boxs. The first box is the number of times that a
task is required. The second box is the number of times that the task was
actually performed.

The code that I attached to the "times done" box checks to see if the user
accidentally switched the values and then offers to switch them back. And all
works fine until . . .

If the user puts in the values of 10 and 9, then the code pops up the
message box saying that the times done is greater than the times required,
even though they are not. If I input 10 and 09, then the code works as
intended.

I am hoping there is a simple solution to this that I have not seen yet.

Will
 
values in a textbox are strings. therefore you get the seemingly wrong
answer.

if clng(textbox2.Value) > clng(textbox1.Value) then

Using clng to convert the text numbers to actual numbers should clear up the
problem.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top