Computing.Net > Forums > Programming > Simple VB.net question

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Simple VB.net question

Reply to Message Icon

Name: Frank Castle
Date: July 30, 2008 at 07:52:07 Pacific
OS: XP Pro
CPU/Ram: 1.4Ghz 2Gb
Product: Toshiba
Comment:

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 am very new to working with .net and 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 a string input and string output and simply want the decimal places to appear.

thanks



Sponsored Link
Ads by Google

Response Number 1
Name: Razor2.3
Date: July 30, 2008 at 09:22:46 Pacific
Reply:

Dim val2 As Decimal = Format(val1,"##0.00")

When you apply formatting, it's no longer a number. val1 should be a String.

I am getting an error "Format not declared"

Try using:
Microsoft.VisualBasic.Strings.Format

It's the Format function you're looking for with its explicit location.

0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Simple VB.net question

VB.NET question: an error www.computing.net/answers/programming/vbnet-question-an-error/8093.html

VB.net question www.computing.net/answers/programming/vbnet-question/7997.html

Aligning decimal output in VB.NET?? www.computing.net/answers/programming/aligning-decimal-output-in-vbnet/8618.html