Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 109
Default textbox validation with 3 conditions

Mr.Rick Rothstein gave me correct vb code for testing two textbox for
(equal)values.
How to codify the following logic with Greater than or less than parameter

I have 2 text boxes viz.TextBox1 and Textbox2 in a userform.TextBox1 has a
archival value from a worksheet source.
Condition1:The Textbox2 can be left blank without entering any
data/value.condition2:But if entry is needed only numeric values(numbers with
or without
decimals) be entered, condition3:and the TextBox2 value should not be greater
than TextBox1.
cursor should not move from the textbox until
correction/rectification done by user.
While rectification if user deletes whole entry and leave the textbox blank,
or
corrects the entry by putting exact values as in TextBox1.

--
Message posted via http://www.officekb.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default textbox validation with 3 conditions

With Me.TextBox2

If .Text < "" And _
(Not IsNumeric(.Text) Or _
Val(.Text) Me.TextBox1.Text) Then

MsgBox "Invalid value"
.SelStart = 0
.SelLength = Len(.Text)
.SetFocus
Exit Sub
End If

'OTHER CODE
End With


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"tkraju via OfficeKB.com" <u16627@uwe wrote in message
news:854f16425e965@uwe...
Mr.Rick Rothstein gave me correct vb code for testing two textbox for
(equal)values.
How to codify the following logic with Greater than or less than parameter

I have 2 text boxes viz.TextBox1 and Textbox2 in a userform.TextBox1 has a
archival value from a worksheet source.
Condition1:The Textbox2 can be left blank without entering any
data/value.condition2:But if entry is needed only numeric values(numbers
with
or without
decimals) be entered, condition3:and the TextBox2 value should not be
greater
than TextBox1.
cursor should not move from the textbox until
correction/rectification done by user.
While rectification if user deletes whole entry and leave the textbox
blank,
or
corrects the entry by putting exact values as in TextBox1.

--
Message posted via http://www.officekb.com



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 109
Default textbox validation with 3 conditions

thank you Bob.Working fine !
one more question.
how to validate date entries in TextBoxes (on Userform),user wants to enter
date values in dd/mm/yy form,after entry and exiting from textbox the textbox
entry be displayed in dd-mmm-yy format.

Bob Phillips wrote:
With Me.TextBox2

If .Text < "" And _
(Not IsNumeric(.Text) Or _
Val(.Text) Me.TextBox1.Text) Then

MsgBox "Invalid value"
.SelStart = 0
.SelLength = Len(.Text)
.SetFocus
Exit Sub
End If

'OTHER CODE
End With

Mr.Rick Rothstein gave me correct vb code for testing two textbox for
(equal)values.

[quoted text clipped - 15 lines]
or
corrects the entry by putting exact values as in TextBox1.


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200806/1

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default textbox validation with 3 conditions

I would use the AfterUpdate event and just check that it is a date, let them
enter it however they want, and reform at it


Private Sub TextBox1_AfterUpdate()
With Me.TextBox1

If IsDate(.Text) Then

.Text = Format(CDate(.Text), "dd-mmm-yy")
Else

MsgBox "Invalid date entry"
.SelStart = 0
.SelLength = Len(.Text)
.SetFocus
End If
End With
End Sub

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"tkraju via OfficeKB.com" <u16627@uwe wrote in message
news:855a96bfe9e31@uwe...
thank you Bob.Working fine !
one more question.
how to validate date entries in TextBoxes (on Userform),user wants to
enter
date values in dd/mm/yy form,after entry and exiting from textbox the
textbox
entry be displayed in dd-mmm-yy format.

Bob Phillips wrote:
With Me.TextBox2

If .Text < "" And _
(Not IsNumeric(.Text) Or _
Val(.Text) Me.TextBox1.Text) Then

MsgBox "Invalid value"
.SelStart = 0
.SelLength = Len(.Text)
.SetFocus
Exit Sub
End If

'OTHER CODE
End With

Mr.Rick Rothstein gave me correct vb code for testing two textbox for
(equal)values.

[quoted text clipped - 15 lines]
or
corrects the entry by putting exact values as in TextBox1.


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200806/1



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 109
Default textbox validation with 3 conditions

Thank you Bob,Please ignore my reply in other thread.Thanks once again.

Bob Phillips wrote:
I would use the AfterUpdate event and just check that it is a date, let them
enter it however they want, and reform at it

Private Sub TextBox1_AfterUpdate()
With Me.TextBox1

If IsDate(.Text) Then

.Text = Format(CDate(.Text), "dd-mmm-yy")
Else

MsgBox "Invalid date entry"
.SelStart = 0
.SelLength = Len(.Text)
.SetFocus
End If
End With
End Sub

thank you Bob.Working fine !
one more question.

[quoted text clipped - 25 lines]
or
corrects the entry by putting exact values as in TextBox1.


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200806/1



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 109
Default textbox validation with 3 conditions

Mr.Bob, thank you but this code has not given me desired results.I entered in
Textbox1 a date as
04/06/08(means 4th June 2008),it converted to 06-Apr-08(6thApril2008).
what is the remedy?

Bob Phillips wrote:
I would use the AfterUpdate event and just check that it is a date, let them
enter it however they want, and reform at it

Private Sub TextBox1_AfterUpdate()
With Me.TextBox1

If IsDate(.Text) Then

.Text = Format(CDate(.Text), "dd-mmm-yy")
Else

MsgBox "Invalid date entry"
.SelStart = 0
.SelLength = Len(.Text)
.SetFocus
End If
End With
End Sub

thank you Bob.Working fine !
one more question.

[quoted text clipped - 25 lines]
or
corrects the entry by putting exact values as in TextBox1.


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200806/1

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 109
Default textbox validation with 3 conditions

Mr.Bob, thank you but this code has not given me desired results.I entered in
Textbox1 a date as
04/06/08(means 4th June 2008),it converted to 06-Apr-08(6thApril2008).
what is the remedy?


Bob Phillips wrote:
I would use the AfterUpdate event and just check that it is a date, let them
enter it however they want, and reform at it

Private Sub TextBox1_AfterUpdate()
With Me.TextBox1

If IsDate(.Text) Then

.Text = Format(CDate(.Text), "dd-mmm-yy")
Else

MsgBox "Invalid date entry"
.SelStart = 0
.SelLength = Len(.Text)
.SetFocus
End If
End With
End Sub

thank you Bob.Working fine !
one more question.

[quoted text clipped - 25 lines]
or
corrects the entry by putting exact values as in TextBox1.


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200806/1

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 171
Default textbox validation with 3 conditions

Mr.Bob,Your code hasn't given me desired results.I entered a date value in
TextBox1, 04/06/08(what I mean 4thJune2008),it converted to 06-Apr-08.I want
result 04-Jun-08.

"Bob Phillips" wrote:

I would use the AfterUpdate event and just check that it is a date, let them
enter it however they want, and reform at it


Private Sub TextBox1_AfterUpdate()
With Me.TextBox1

If IsDate(.Text) Then

.Text = Format(CDate(.Text), "dd-mmm-yy")
Else

MsgBox "Invalid date entry"
.SelStart = 0
.SelLength = Len(.Text)
.SetFocus
End If
End With
End Sub

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"tkraju via OfficeKB.com" <u16627@uwe wrote in message
news:855a96bfe9e31@uwe...
thank you Bob.Working fine !
one more question.
how to validate date entries in TextBoxes (on Userform),user wants to
enter
date values in dd/mm/yy form,after entry and exiting from textbox the
textbox
entry be displayed in dd-mmm-yy format.

Bob Phillips wrote:
With Me.TextBox2

If .Text < "" And _
(Not IsNumeric(.Text) Or _
Val(.Text) Me.TextBox1.Text) Then

MsgBox "Invalid value"
.SelStart = 0
.SelLength = Len(.Text)
.SetFocus
Exit Sub
End If

'OTHER CODE
End With

Mr.Rick Rothstein gave me correct vb code for testing two textbox for
(equal)values.
[quoted text clipped - 15 lines]
or
corrects the entry by putting exact values as in TextBox1.


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200806/1




  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 421
Default textbox validation with 3 conditions

Hi Tungana,

Bob's code worked for me.

I could reproduce your result if I employed
US date settings on my system and I entered
the date as 04/06/08.

However, to enter the date 4th June 2008,
a US user would type 6/04/08 and a
European user would type 4/6/08.

In either case, Bob's code would provide
the the required (June) date in dd-mmm-yy
format, as requested.



---
Regards.
Norman


"TUNGANA KURMA RAJU" wrote in
message ...
Mr.Bob,Your code hasn't given me desired results.I entered a date value in
TextBox1, 04/06/08(what I mean 4thJune2008),it converted to 06-Apr-08.I
want
result 04-Jun-08.

"Bob Phillips" wrote:

I would use the AfterUpdate event and just check that it is a date, let
them
enter it however they want, and reform at it


Private Sub TextBox1_AfterUpdate()
With Me.TextBox1

If IsDate(.Text) Then

.Text = Format(CDate(.Text), "dd-mmm-yy")
Else

MsgBox "Invalid date entry"
.SelStart = 0
.SelLength = Len(.Text)
.SetFocus
End If
End With
End Sub

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my
addy)

"tkraju via OfficeKB.com" <u16627@uwe wrote in message
news:855a96bfe9e31@uwe...
thank you Bob.Working fine !
one more question.
how to validate date entries in TextBoxes (on Userform),user wants to
enter
date values in dd/mm/yy form,after entry and exiting from textbox the
textbox
entry be displayed in dd-mmm-yy format.

Bob Phillips wrote:
With Me.TextBox2

If .Text < "" And _
(Not IsNumeric(.Text) Or _
Val(.Text) Me.TextBox1.Text) Then

MsgBox "Invalid value"
.SelStart = 0
.SelLength = Len(.Text)
.SetFocus
Exit Sub
End If

'OTHER CODE
End With

Mr.Rick Rothstein gave me correct vb code for testing two textbox
for
(equal)values.
[quoted text clipped - 15 lines]
or
corrects the entry by putting exact values as in TextBox1.

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200806/1





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
Textbox validation [email protected] Excel Programming 9 May 29th 08 09:59 AM
textbox validation TC[_6_] Excel Programming 2 October 13th 04 03:19 AM
textbox value validation girapas[_2_] Excel Programming 1 July 19th 04 12:16 PM
Textbox validation phreud[_17_] Excel Programming 6 June 27th 04 07:49 PM
textbox validation Beginner[_2_] Excel Programming 1 April 7th 04 07:46 PM


All times are GMT +1. The time now is 01:11 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"