Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting types

Status
Not open for further replies.

DreadPirate

Technical User
Sep 3, 2001
8
US
Greetings,

Simple problem, but it seems to be more complex than I am, apparently.

I'm trying to convert a number in a text box into an integer by using the Cint command. VB seems opposed to the idea; it keeps giving me "Type Mismatch" errors. Here's what I'm doing:

CityNo = CInt(CityNumber.Text)
CityNo + Miles = TotalNumber



The problem, apparently, is with the first line. But what it is is beyond me. I have declared CityNo as an integer (as well as miles and TotalNumber). Any help would be greatly appreciated.

Thanks.

{R}
 
I'm assuming that you typed in your example rather than cutting and pasting it, since the second line is somewhat wrong.

You'll get the Type Mismatch error if your CityNumber textbox contains anything other than a pure number. Are you absolutely sure that this is the case at the point your routine is called?
 

Hai

You declare the cityno as double (Data type)
because simply declare integer it means only it takes upto 32000 I think yr no it exceeds.
Pl declare as Double it works

secondly
CityNo = CInt(CityNumber.Text)
you write
TotalNumber= CityNo + Miles
definetly it works

shanmugham


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top