×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

#### Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

# converting a String to a value that could be manipulated

## converting a String to a value that could be manipulated

(OP)
I need to find a way to take, $4,500.00(String) and convert it to 4500. MyValue=MyTerminal.GetString 14, 18. Is there an easy way to do this? I have already created the hard, long way. My code can sometimes be long-winded like my brother-in-law. I have tried to wrap my head around it, but my code consists of determining the size of the amount, then taking it apart piece by piece, then putting it back together. ### RE: converting a String to a value that could be manipulated hi, I don't know if Extra VB has the CCur() function to convert to currency. Even CDbl() would work. [code] Dim s As String, c As Currency s = "$45,000.24"
c = CCur(s)
[code]

Skip,

Just traded in my old subtlety...
for a NUANCE!

### RE: converting a String to a value that could be manipulated

(OP)
Hi Skip,

I believe I had tried something similar in the past. I have not tried the currency call though, and I will try on monday or tuesday and get back to you. I gave up when it kept coming back with 0.

### RE: converting a String to a value that could be manipulated

(OP)
Hi Skip,

I tried it, this is what I ran.

#### CODE

Sub main

dim c As Currency, S As String, d As Double

s="$45,000.00" c=CCur(s) d=CDbl(c) msgbox c & " " & d End Sub bot c and d returned 45 so I tried s="$45,454.00"
same result.

ccur does not like the ","(comma)or the"."(period)

removing the comma gave, 45454

any other thoughts you might have?

### RE: converting a String to a value that could be manipulated

That must be a limitation of Extra BASIC.

I have no such issues in Microsoft applications VBA.

So try this...

#### CODE

Sub main

dim c As Currency, S As String, d As Double

s="\$45,000.00"

s = left(s, instr(s,",")-1) & right(s, len(s)-instr(s,","))

c=CCur(s)

d=CDbl(c)

msgbox c & " " & d

End Sub

Skip,

Just traded in my old subtlety...
for a NUANCE!

### RE: converting a String to a value that could be manipulated

(OP)
Hey Skip,

Your suggestion did the trick. Your code is a lot clearer, in just one line the I could do in 5 or 6. I think I am am finally learning here. The help files are great, but its nice to know there's a place I could go that makes things seem that much clearer. Eurika!

Thanks again, Skip:0)

Ted,

#### Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

#### Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Close Box

# Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!