View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
TUNGANA KURMA RAJU TUNGANA KURMA RAJU is offline
external usenet poster
 
Posts: 171
Default validation for 10 text boxes

Thanks Norman,I will check with your code and let you know whether they works
are not.I will reply soon.

"Norman Jones" wrote:

Hi Tungana,

Your validation requirementa appear
vague.

However, as a starting point, try
somethiing like:


'============
Option Explicit

Private Sub CommandButton1_Click()
Dim i As Long
Dim sStr As String

With Me
If .TextBox6.Value < vbNullString _
And .TextBox2.Value < vbNullString Then
If CDbl(.TextBox6.Value) _
CDbl(.TextBox2.Value) Then
'\\ Do something, e.g.:
MsgBox Prompt:="TextBox6 value must " _
& "be lower than TextBox2"
End If
End If

For i = 1 To 10
If .Controls("TextBox" & i).Value = _
vbNullString Then
sStr = sStr _
& .Controls("TextBox" & i).Name _
& vbNewLine
End If
Next i
End With
If Len(sStr) Then
MsgBox Prompt:="The TextBoxes " _
& vbNewLine & sStr _
& " musthave a value inserted"
End If
End Sub
'<<============



---
Regards.
Norman
"TUNGANA KURMA RAJU" wrote in
message ...
1.how to validate a collection of 10 boxes for numbers only.I know code
for 1
textbox
like
Private Sub TextBox1_change
If TextBox1= vbNullstring Then Exit Sub .... so..so
what validation code for collection of controls in short will do ?
2. I want validation for a TextBox6 for a number not greater than other
TextBox2 in same userForm.