View Single Post
  #1 (permalink)  
Old October 8th, 2012, 02:10 PM
jbburf jbburf is offline
Authorized User
Points: 43, Level: 1
Points: 43, Level: 1 Points: 43, Level: 1 Points: 43, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2012
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default Int to Char and Char to Int Function

I am trying to convert an int to a three character string. I need to convert 1 into "001."

The built in INT() and CHAR() functions do not work.

I have created a workaround by using switch statements which works in the short term but is not an elegant solution.

Code:
Function Int_to_Char(temp As Integer) As String
    Select Case temp
    Case 1
        Int_to_Char = "001"
    Case 2
        Int_to_Char = "002"
    Case 3
        Int_to_Char = "003"
...
And:

Code:
Function Char_to_Int(temp As String) As Integer
    Select Case temp
    Case "001"
        Char_to_Int = 1
    Case "002"
        Char_to_Int = 2
    Case "003"
...
Can anyone show me a quick way to do the above conversion?