ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Userform (https://www.excelbanter.com/excel-programming/413053-userform.html)

Paul

Userform
 
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

Jim Rech

Userform
 
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
"Paul" wrote in message
...
| 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




All times are GMT +1. The time now is 01:16 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com