convert string to integer

Results 1 to 3 of 3

Thread: convert string to integer

  1. #1
    Join Date
    Dec 1969

    Default convert string to integer

    Hi all -<BR><BR>How do I convert a string value stored in a variable into an integer?<BR><BR>Situation: I&#039;m pulling a number from an Oracle table [as a counter for the unique ID] and storing that number into a variable. Then I&#039;m inserting that variable into the database field but it is currently in string format. How do I code it to understand that number is an integer?<BR><BR>THANKS!!!!

  2. #2
    Join Date
    Dec 1969

    Default Cint() or Clng()<eop>.


  3. #3
    Join Date
    Dec 1969

    Default RE: convert string to integer

    It shouldn&#039;t come out of the database as a string unless you are using the GetString method. In any event, here is a safe way to convert a string into an integer:<BR><BR>str = "23"<BR>Response.Write 12 + ToInt(str)<BR><BR>Function ToInt(sValue)<BR> If IsNull(sValue) Then<BR> ToInt = 0<BR> ElseIf IsNumeric(sValue) Then<BR> ToInt = CInt(sValue)<BR> Else<BR> ToInt = 0<BR> End If<BR>End Function

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts