Userform

P

Paul

Hi,

I've got a userform with different textboxes, I'm using the following code
to insert the dates into the textboxes and to validate that date B is not
less or equal to date A:

If ALLOCATION.ComButton3.Caption = "X" Then
ALLOCATION.TextBox21.Value = Calendar1.Day & TextBox1.Value & "Z" & n &
Calendar1.Year
ALLOCATION.TextBox151.Value = Calendar2.Day & TextBox2.Value & "Z" & m &
Calendar2.Year
frmCalendar.Hide
If ALLOCATION.TextBox151.Value < ALLOCATION.TextBox21.Value Or _
ALLOCATION.TextBox151.Value = ALLOCATION.TextBox21.Value Then
MsgBox "msg"
ALLOCATION.TextBox151.Value = ""
frmCalendar.Show
End If
Unload Me
ALLOCATION.ComButton3.Caption = "Y"

My problem is that when I have 141315ZMAR2008 as my first date (A) I'll get
the warningmessage if date B is 141315ZJUL2008, so for some way the code only
looks at the first part of the date, instead of the complete part.

Does anybody have an idea?

Cheers,

Paul
 
J

Jim Rech

You may consider (A) 141315ZMAR2008 and (B) 141315ZJUL2008 to be dates but
since they are not in a date format that VB recognizes they are just strings
to it.

Since at the first point they differ, character 8, (B) has "J" and (A) has
"M", VB considers B to be less than A.

--
Jim
| Hi,
|
| I've got a userform with different textboxes, I'm using the following code
| to insert the dates into the textboxes and to validate that date B is not
| less or equal to date A:
|
| If ALLOCATION.ComButton3.Caption = "X" Then
| ALLOCATION.TextBox21.Value = Calendar1.Day & TextBox1.Value & "Z" & n &
| Calendar1.Year
| ALLOCATION.TextBox151.Value = Calendar2.Day & TextBox2.Value & "Z" & m
&
| Calendar2.Year
| frmCalendar.Hide
| If ALLOCATION.TextBox151.Value < ALLOCATION.TextBox21.Value Or _
| ALLOCATION.TextBox151.Value = ALLOCATION.TextBox21.Value Then
| MsgBox "msg"
| ALLOCATION.TextBox151.Value = ""
| frmCalendar.Show
| End If
| Unload Me
| ALLOCATION.ComButton3.Caption = "Y"
|
| My problem is that when I have 141315ZMAR2008 as my first date (A) I'll
get
| the warningmessage if date B is 141315ZJUL2008, so for some way the code
only
| looks at the first part of the date, instead of the complete part.
|
| Does anybody have an idea?
|
| Cheers,
|
| Paul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top