Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ckecking for null from text box

Status
Not open for further replies.

asterof53

Programmer
May 26, 2015
5
US
Button calls this form called frmKetpadHiLo


frmKeypadHiLo.Caption = "HS301 PID SP"
frmKeypadHiLo.TheTextHiLo = 10.0
frmKeypadHiLo.TheTextHi = 100
frmKeypadHiLo.TheTextLo = 1
frmKeypadHiLo.Show

you enter a value in a textbox and click done button value is returned back to this script

If frmKeypadHiLo.TheTextHi <> "" Then 'suppose to check to be sure there was data in checkbox
Value1 = frmKeypadHiLo.TheTextHiLo * 10
End If

the textbox will only contain numeric text
this checking does not work

tried

Value1 = VAL(frmKeypadHiLo.TheTextHiLo) * 10
If Value1 > 0 Then but this did not work either

any one have a solution
 
hi,

I used your code, named my UserForm frmKeypadHiLo and got 100 in Value1.

How are you testing the contents of Value1?
 
try this

Button calls this form called frmKetpadHiLo


frmKeypadHiLo.Caption = "HS301 PID SP"
frmKeypadHiLo.TheTextHiLo = ""
frmKeypadHiLo.TheTextHi = 100
frmKeypadHiLo.TheTextLo = 1
frmKeypadHiLo.Show

you enter a value in a textbox and click done button value is returned back to this script

If frmKeypadHiLo.TheTextHi <> "" Then 'suppose to check to be sure there was data in checkbox
Value1 = frmKeypadHiLo.TheTextHiLo
End If

the textbox will only contain numeric text
this checking does not work

tried

Value1 = VAL(frmKeypadHiLo.TheTextHiLo)
If Value1 > 0 Then but this did not work either

any one have a solution

you will see it will fail the test
 
you can add a label to the form
and label1.caption = Value1
 
You have [tt]If frmKeypadHiLo.TheTextHi <> ""[/tt]. There is 100 in this textbox, so Value1 stays unchanged or not initialised after this condition testing. Is it what you intend?

combo
 
no I need to make sure there is a value of
frmKeypadHiLo.TheTextHi = 100
frmKeypadHiLo.TheTextLo = 1
No greater than the value assigned to frmKeypadHiLo.TheTextHi
and no less than the value assigned to frmKeypadHiLo.TheTextLo = 1
and it must be a number not a space or null
 
Rather bold:
ValHiLo=val(frmKeypadHiLo.TheTextHiLo)
ValHi=val(frmKeypadHiLo.TheTextHi)
ValHi=val(frmKeypadHiLo.TheTextLo)

Now you can test values if they are within range. The drawback is that text and empty textbox are converted to 0. Alternatively the easiest would be building a function that tests character by character if string has proper structure: non-zero length, maximum one decimal separator and all other characters are digits (for positive numbers).

combo
 
Yea I tried using the val function

ValHiLo=val(frmKeypadHiLo.TheTextHiLo)
ValHi=val(frmKeypadHiLo.TheTextHi)
ValLo=val(frmKeypadHiLo.TheTextLo)



I tried
If (ValHiLo > ValLo) AND (ValHiLo <= ValHi) THEN
'do true code
Else
'Do false code
End If

It always seemed to do the true code even with a space in the ValHiLo
 
Try the following:
Code:
If frmKeypadHiLo.TheTextHi <> "" OR frmKeypadHiLo.TheTextHi <> 0 Then 'suppose to check to be sure there was data in checkbox
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top