Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old January 7th, 2005, 05:23 AM
kmalika kmalika is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 24 kmalika User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 24 m
Reputation Power: 0
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 .

Reply With Quote
  #2  
Old January 8th, 2005, 01:52 AM
satishkumarj satishkumarj is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 109 satishkumarj User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 1 h 37 m
Reputation Power: 4
Arrow TypeName

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.

Reply With Quote
  #3  
Old January 8th, 2005, 04:39 PM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
ASP Free God 45th Plane (27000 - 27499 posts)
 
Join Date: Sep 2004
Location: Israel
Posts: 27,250 Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)  Folding Points: 354839 Folding Title: Super Ultimate Folder - Level 1Folding Points: 354839 Folding Title: Super Ultimate Folder - Level 1Folding Points: 354839 Folding Title: Super Ultimate Folder - Level 1Folding Points: 354839 Folding Title: Super Ultimate Folder - Level 1Folding Points: 354839 Folding Title: Super Ultimate Folder - Level 1Folding Points: 354839 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Months 1 Week 6 Days 10 h 43 m 15 sec
Reputation Power: 1778
Quote:
Originally Posted by kmalika
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 .

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
 

Reply With Quote
  #4  
Old January 9th, 2005, 11:44 PM
kmalika kmalika is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 24 kmalika User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 24 m
Reputation Power: 0
thanks Satish .my code is working well.
thanks
madhu

Reply With Quote
  #5  
Old January 10th, 2005, 12:43 AM
kmalika kmalika is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 24 kmalika User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 24 m
Reputation Power: 0
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

Reply With Quote
  #6  
Old January 10th, 2005, 12:59 AM
satishkumarj satishkumarj is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 109 satishkumarj User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 1 h 37 m
Reputation Power: 4
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

Reply With Quote
  #7  
Old January 10th, 2005, 01:26 AM
kmalika kmalika is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 24 kmalika User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 24 m
Reputation Power: 0
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

Reply With Quote
  #8  
Old January 10th, 2005, 03:43 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
ASP Free God 45th Plane (27000 - 27499 posts)
 
Join Date: Sep 2004
Location: Israel
Posts: 27,250 Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)  Folding Points: 354839 Folding Title: Super Ultimate Folder - Level 1Folding Points: 354839 Folding Title: Super Ultimate Folder - Level 1Folding Points: 354839 Folding Title: Super Ultimate Folder - Level 1Folding Points: 354839 Folding Title: Super Ultimate Folder - Level 1Folding Points: 354839 Folding Title: Super Ultimate Folder - Level 1Folding Points: 354839 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Months 1 Week 6 Days 10 h 43 m 15 sec
Reputation Power: 1778
Quote:
Originally Posted by satishkumarj
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

nope, TypeName is not so smart.
to check if something is date, try IsDate function:
if IsDate(text1.text) then
msgbox "date!"
end if

Reply With Quote
  #9  
Old January 10th, 2005, 04:22 AM
kmalika kmalika is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 24 kmalika User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 24 m
Reputation Power: 0
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

Reply With Quote
  #10  
Old January 10th, 2005, 04:28 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
ASP Free God 45th Plane (27000 - 27499 posts)
 
Join Date: Sep 2004
Location: Israel
Posts: 27,250 Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)  Folding Points: 354839 Folding Title: Super Ultimate Folder - Level 1Folding Points: 354839 Folding Title: Super Ultimate Folder - Level 1Folding Points: 354839 Folding Title: Super Ultimate Folder - Level 1Folding Points: 354839 Folding Title: Super Ultimate Folder - Level 1Folding Points: 354839 Folding Title: Super Ultimate Folder - Level 1Folding Points: 354839 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Months 1 Week 6 Days 10 h 43 m 15 sec
Reputation Power: 1778
sorry, I don't undersrand what you mean. IsDate() will check if the given value is date, no matter year month or day...

Reply With Quote
  #11  
Old January 10th, 2005, 04:45 AM
kmalika kmalika is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 24 kmalika User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 24 m
Reputation Power: 0
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.

Reply With Quote
  #12  
Old January 10th, 2005, 05:08 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
ASP Free God 45th Plane (27000 - 27499 posts)
 
Join Date: Sep 2004
Location: Israel
Posts: 27,250 Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)  Folding Points: 354839 Folding Title: Super Ultimate Folder - Level 1Folding Points: 354839 Folding Title: Super Ultimate Folder - Level 1Folding Points: 354839 Folding Title: Super Ultimate Folder - Level 1Folding Points: 354839 Folding Title: Super Ultimate Folder - Level 1Folding Points: 354839 Folding Title: Super Ultimate Folder - Level 1Folding Points: 354839 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Months 1 Week 6 Days 10 h 43 m 15 sec
Reputation Power: 1778
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.

Reply With Quote
  #13  
Old January 10th, 2005, 05:54 AM
kmalika kmalika is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 24 kmalika User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 24 m
Reputation Power: 0
leave it u tell me conversion function of date .how to convert a data into date type

Reply With Quote
  #14  
Old January 10th, 2005, 06:26 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
ASP Free God 45th Plane (27000 - 27499 posts)
 
Join Date: Sep 2004
Location: Israel
Posts: 27,250 Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)  Folding Points: 354839 Folding Title: Super Ultimate Folder - Level 1Folding Points: 354839 Folding Title: Super Ultimate Folder - Level 1Folding Points: 354839 Folding Title: Super Ultimate Folder - Level 1Folding Points: 354839 Folding Title: Super Ultimate Folder - Level 1Folding Points: 354839 Folding Title: Super Ultimate Folder - Level 1Folding Points: 354839 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Months 1 Week 6 Days 10 h 43 m 15 sec
Reputation Power: 1778
in vbscript you have CDate, not sure if this apply in VB as well:
myDate=CDate("11/25/04")

Reply With Quote