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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing Strings to Integers

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hello,

I'm very new to vbscript (it's bee a while since i've worked with visual basic 5 also). Anyways. I've tried using the val function to change a string to an integer but it won't work! My strings are in the currency format. Here's some of my code...

'subroutine for changing a lable depending on what the
'user selects in the dropdown box.


Sub cmbScreen_Change()
Select Case Document.frmTTX.cmbScreen.Value
Case "V700 with 14.1'' XGA TFT LCD & Li-Ion Battery"
Document.frmTTX.lblScreen.Caption="$1,250.00"
' ...blah blah....


'Here I am trying to calculate the total cost.
'The Val function isn't working. HELP!

Sub cmdCalcSysComp_OnClick()
dim cost
cost = Val(Document.frmTTX.lblScreen.Caption)
Document.frmTTX.lblTotalSysComp.Caption=cost

End Sub

Is there another way to go about this?
 
Have you tried CDbl (Convert to Double precision)? Put the $ in front of the text box, and you'll have a lot less trouble with this kind of thing.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top