how do i make a string variable into an integer variable.

something like:

number = String

i've always only converted it from a textbox now i'm having trouble using variables.. not sure why it's different..

monthtxt = Mid(CardLength, 1, countnum)
                    yeartxt = Mid(CardLength, i + 1, Yearstart)



                    isvalid = Integer.TryParse(monthtxt.text, numberstyles.currency, _
                        numberformatinfo.CurrentInfo, Month)

basically i want monthtxt to become the integer form in Month.

i think this would be the only important part..

Recommended Answers

All 5 Replies

dim intX as integer
intX = Cint("strTEXTE")

>>>casting functiond CDbl, CLng etc

You need to use convertion function.

BTW which version of VB you are using ?
Is it Vb 6.0

hi,
you can get that value as numer using Val() function right....!!!

With regards
Vnekatramasamy SN

First thing I would observe is that maybe you should use a Byte since there are only 12 month. Otherwise, use the convert functions (cInt() or cByte()) to convert to the number. I. e., after your Monthtxt statement, add intMonth=cInt(monthtext). You will, of course, want to declare intMonth as an integer (although I do suggest using bytMonth and the cByte() function).

how do i make a string variable into an integer variable.

something like:

number = String

i've always only converted it from a textbox now i'm having trouble using variables.. not sure why it's different..

monthtxt = Mid(CardLength, 1, countnum)
                    yeartxt = Mid(CardLength, i + 1, Yearstart)



                    isvalid = Integer.TryParse(monthtxt.text, numberstyles.currency, _
                        numberformatinfo.CurrentInfo, Month)

basically i want monthtxt to become the integer form in Month.

i think this would be the only important part..

alright, thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.