Shortcuts

Formatting VB

Hello programmer's. I have the following VB script in VS2005, ASP.NET that writes sql data to a text file. Can someone help me understanding whether I can format the paydate and checkamt fields? Please see the two sample format problems below. I need
to reformat certain values. Do I do the formatting in the Dim section or in the if not – then section or in the streamwriter section? Thank you.

Two Sample Format Problems:

1. Using the below VB script in asp.net the “paydate” is outputting to the checkfile.txt as 1/1/2010. I need to format it so it outputs as 1/1/10.

2. Using the below VB script in asp.net the “checkamt” is outputting to the checkfile.txt as 848.7000. I need to format it so it outputs as 848.70.

Re: Formatting VB

mahonek

Do I do the formatting in the Dim section or in the if not – then section or in the streamwriter section?

The last post had the correct formatting syntax, but I will say in principal I would apply the formatting only to the place that requires the modification; which in your case would be on the StreamWriter. Therefore I would do the following:

The reason is, what if you needed those variables later but had already applied the formatting? If that was your requirment then it would be proper to do them upon declaration. However, if you ever ported this code later to objects and the values were on
properties, you may want the raw values exposed so the caller can format as they wish as opposed to preformatting to a specified style.