View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ali Baba Ali Baba is offline
external usenet poster
 
Posts: 16
Default User entry correction

Hi

I have a userform with a textbox to enter a formula. The user is required
to enter a formula as in the following examples

X1+3*X
5+X1
X1+X2-10*X3+4

and so on

I want to make sure that the user enters the correct format. This would
include:
1 €“ enter only X values
2 €“ X are in upper case
3 - asterix between the number and X (eg 5*X1)

This is what I have done so far

--------------------------------------------------------------------------------------
Dim PointToX As Single, PointToAsterix As Single

StrFunction = txtFunction.Text
StrFunction = Replace(StrFunction, "x", "X")
StrFunction = Replace(StrFunction, " ", "")
PointToX = InStr(1, StrFunction, "X") 'First "X" occurrence
If PointToX = 0 Then
GoTo FunctionInputError
Else

FunctionInputError:
txtFunction.Text.SetFocus
txtFunction.Text.SelStart = 1
txtFunction.Text.SelLength = Len(txtFunction.Text)
Exit Sub

End Sub


Any help??