Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 171
Default validation for 10 text boxes

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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default validation for 10 text boxes

I think you will need to answer a few questions before anyone will be able
to help you out...

1. What do you mean when you say "numbers"... integers only or are floating
point values allowed?

2. When are you attempting to do your "validation"... when the user is
typing into the TextBox itself, or afterwards when all the TextBoxes have
been filled in and an OK button is pressed?

3. In your example labeled #2, did you have something more in mind than
TextBox6.Value < TextBox2.Value?

With respect to my #2 above, I would note that your example show you using a
Change event for you validation which suggests you are trying to validate
the entry as it is being typed in. I would point out that you cannot use
only the Change event by itself to validate values... the user will always
be able to bypass your validation routine by pasting invalid data into the
TextBox.

Rick


"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.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 421
Default validation for 10 text boxes

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.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 171
Default validation for 10 text boxes

Thanks Rick,
1.numbers means numeric values with 2 decimals
a.leaving the textbox without entering any value,that means blank textboxes
b. for sometext boxes entering a numeric value mandatory.
2.Afterwards ,when all the text boxes filled.
3.I have a calculated textbox value in TextBox2,fetched from a w/sheet.For
example
textBox2 represents "Eligible amount of loan",Textbox6 represents "amount of
loan to be given".Therefore the value in Textbox6 should not be greater than
value in TextBox2.
som

"Rick Rothstein (MVP - VB)" wrote:

I think you will need to answer a few questions before anyone will be able
to help you out...

1. What do you mean when you say "numbers"... integers only or are floating
point values allowed?

2. When are you attempting to do your "validation"... when the user is
typing into the TextBox itself, or afterwards when all the TextBoxes have
been filled in and an OK button is pressed?

3. In your example labeled #2, did you have something more in mind than
TextBox6.Value < TextBox2.Value?

With respect to my #2 above, I would note that your example show you using a
Change event for you validation which suggests you are trying to validate
the entry as it is being typed in. I would point out that you cannot use
only the Change event by itself to validate values... the user will always
be able to bypass your validation routine by pasting invalid data into the
TextBox.

Rick


"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.



  #5   Report Post  
Posted to microsoft.public.excel.programming
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.





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 171
Default validation for 10 text boxes

Mr.Norman,
Thanks for your code,but it is not working well.whenever i am putting text
in textbox2,or Text box6 ,error is coming,for debugging.Second part of
question for validation of other textboxes ,if I enters text they are
accepting the text,so validation for numeric numbers is not functioning.

"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.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Validation drop-down boxes Tami Excel Worksheet Functions 14 September 21st 09 03:57 AM
User Form Text Boxes - Copy format of text boxes NDBC Excel Discussion (Misc queries) 3 July 2nd 09 02:02 AM
Data validation boxes, outputting a final number from the boxes MDH Excel Discussion (Misc queries) 1 November 16th 06 12:41 AM
validation list boxes Chris Excel Programming 4 August 11th 06 04:34 PM
Dynamic Comments/Validation/Text Boxes George Andrews Excel Programming 0 May 16th 05 10:20 PM


All times are GMT +1. The time now is 12:22 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"