formatting decimal?

Frank Castle

New member
Joined
Jul 30, 2008
Messages
2
Programming Experience
10+
new to VB.net and have the following issue

I am wanting to receive an XML String field with a decimal in it and add it to another XML string field with a decimal value in it. However, during type conversion the decimal positions are truncated if they are zero, this is not desirable.

for example. String 100.00 + String 120.00 = 220.00
Return val As Decimal produces 220

I was wondering if someone could tell me the proper way to code this snippet. I am getting an error "Format not declared"

Public Function Reformat(ByVal val1 As Decimal) As Decimal
Dim val2 As Decimal = Format(val1,"##0.00")
Return val2
End Function

I am using this code inside of a Biztalk functoid in a map between an XML string input and an XML string output and simply want the decimal places to appear.

thanks
 
Last edited:
You're confusing numeric values and string formatting. Use ToString method to specify the string formatting for the data value. for example val.ToString("n2")
Read more about it starting at Formatting Overview
 
Correct me if I am wrong, but I am bringing the String in as a Decimal, so I am wanting to do some math then output a Decimal to a String field. please see my code included... This is simply to make sure we are on the same page

edit:
please disregard. Your information proved to be helpful and complete. Thank you
 
Back
Top