|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
how to compare a textbox as string
hi all
actually i'm working in vb6.i want to compare my textbox text as string type and long type and also date and boolean type .means i want to write like this: if text1.text=string then msgbox"string" elseif text1.text=long then msgbox"long" end if means i want to compare with different datatypes . plz help me . |
|
#2
|
|||
|
|||
|
Hi Madhu,
Code:
If TypeName(text1.text) = "String" then Msgbox "String" ElseIf TypeName(text1.text) = "Long" then Msgbox "Long" End If Hope this will helps you. Regards, Satish Kumar J. |
|
#3
|
||||
|
||||
|
Quote:
the Text property will always be string, as far as i know... you'll have to check if the value is numeric or not with such code: Code:
If IsNumeric(text1.Text) Then
MsgBox "number"
Else
MsgBox "string"
End If
|
|
#4
|
|||
|
|||
|
thanks Satish .my code is working well.
thanks madhu |
|
#5
|
|||
|
|||
|
sorry satish
its not working .i have done for all these ,u tell me only for "date".how will i check wheather textbox text is of "date" type or not. thanks |
|
#6
|
|||
|
|||
|
Hi Madhu,
It will also work for date also . for example ur text box contains 01/01/2005 then this fucntion will return the string "Date" May be ur entering invalid date check once again and let me know. Regards, Satish |
|
#7
|
|||
|
|||
|
your code is not working with string,date and long even.my date returns "03/20/05" and i cannot even change the format .tell me how can i check for date and also for boolean.don't borther abt string and long ,i have done it by another way.but this date and boolean is not working
thanks |
|
#8
|
||||
|
||||
|
Quote:
nope, TypeName is not so smart. to check if something is date, try IsDate function: if IsDate(text1.text) then msgbox "date!" end if |
|
#9
|
|||
|
|||
|
thanks for replay .isdate is working for all dates but it coudn't check year means give me a type of function which first check year then month and then date.
thanks |
|
#10
|
||||
|
||||
|
sorry, I don't undersrand what you mean. IsDate() will check if the given value is date, no matter year month or day...
|
|
#11
|
|||
|
|||
|
no no actually i'm checking the dates from my database
for e.g if date is between "11/25/04" and "03/18/05" then isdate function is correct when both dates between the same year but when dates is between two years then it gives no ny values. actually i caanot convince u very clearly .actually i'm using flexgrid and user has to feed dates in two cells that should be checked from the database. |
|
#12
|
||||
|
||||
|
sorry, can't understand what you want, also I don't have any idea what is flexgrid, I fear I can't help much further.
|
|
#13
|
|||
|
|||
|
leave it u tell me conversion function of date .how to convert a data into date type
|
|
#14
|
||||
|
||||
|
in vbscript you have CDate, not sure if this apply in VB as well:
myDate=CDate("11/25/04") |