VBA: set a condition on a textbox
Solved
feriadax
Posted messages
15
Registration date
Status
Member
Last intervention
-
feriadax Posted messages 15 Registration date Status Member Last intervention -
feriadax Posted messages 15 Registration date Status Member Last intervention -
Hello,
I have been getting into VBA for the past two weeks. So far, I'm managing pretty well, but I have a little issue.
I am creating a Userform interface with fields to fill out to finally launch a calculation.
Among these fields, there is a textbox that has a default value which is the max value. However, I want this value to be replaceable by the user's choice, as long as it is lower than the max value (display an error message if the value is greater than the max). I tried to do this with an "If Then Else" function, but it does not work.
What could I do according to you?
Thank you in advance for your answers.
See you later.
Macarel
I have been getting into VBA for the past two weeks. So far, I'm managing pretty well, but I have a little issue.
I am creating a Userform interface with fields to fill out to finally launch a calculation.
Among these fields, there is a textbox that has a default value which is the max value. However, I want this value to be replaceable by the user's choice, as long as it is lower than the max value (display an error message if the value is greater than the max). I tried to do this with an "If Then Else" function, but it does not work.
What could I do according to you?
Thank you in advance for your answers.
See you later.
Macarel
Configuration: Windows XP Internet Explorer 7.0
2 answers
Hello!
Well, I code with Visual Basic, I would do:
Put this at the lost focus
Best regards
--
“One must have already learned a lot to know how to ask what one does not know.”
Jean-Jacques ROUSSEAU
Well, I code with Visual Basic, I would do:
if val(textbox1.text)>max value then msgbox "The value is greater than the max value else the rest of your code end if
Put this at the lost focus
Best regards
--
“One must have already learned a lot to know how to ask what one does not know.”
Jean-Jacques ROUSSEAU