Hi,
Im using the following function
Public Function CheckText(MyText As String) As Boolean
'function returns True if text is OK else returns False
If MyText = "" Then
CheckText = False
Exit Function
End If
If Not IsNumeric(MyText) Then
CheckText = False
Exit Function
End If
'If we get to here, MyText is a number
' So set function to true
CheckText = True
End Function
and then calling it when I enter data in a text box to stop errors I was getting if the box was empty or didn't have a number in it.
The code is
Private Sub txtsupplyfo2_Change()
If CheckText(txtsupplyfo2.Text) = True Then
'do the calculations for related data
txtmaxpo2.Text = txtsupplyfo2.Text * txtbar.Text
txtfio2.Text = ((txttotaldump.Text * txtsupplyfo2.Text) - txtconsumption.Text) / (txttotaldump.Text - txtconsumption.Text)
Else
txtsupplyfo2.Text = ""
End If
End Sub
The problem is....in the calculation I can have txtsupplyfo2.Text with a value greater than 1 but with this code I am only able to enter whole numbers.
How can I change it to let decimals be entered. Or should I just have the user enter a whole number (%) and then do a calculation to make the number a fraction before I use it to calculate the other visible data?
please help.
Thanks,
Scott
PS Does anyone here know where I can get some live one on one lessons or training for vb in Sydney, Australia?


Reply With Quote