chris klein
Registered User.
- Local time
- Today, 11:18
- Joined
- Dec 19, 2002
- Messages
- 69
I'm using Access VBA to write numeric values (double) from the current record on a form to a text file.
Each line of the text file has to be formatted as a series of 16-character-long units: For example (using _ to indicate a blank)
"254.01__________23.0001_________45.045609_______"
I get the 16-character units using the following function, where PS is assigned the numeric value:
Public Function PadStr(ToLen, PS)
ExistLen = Len(PS)
AddLen = ToLen - ExistLen
If AddLen > 0 Then
For n = 1 To AddLen
PS = PS & " "
Next n
End If
PadStr = PS
End Function
An example is PadStr(16,Me![calcium])
This function works fine BUT, it strips trailing 0s, and it strips the decimal point if the number is an integer value. For example:
250.010 is returned as "250.01__________" (number followed by 10 blanks) and
250.0 is returned as "250_____________"
IS THERE SOME WAY to prevent this stripping, to get:
"250.010_________" and
"250.0___________" ??
Each line of the text file has to be formatted as a series of 16-character-long units: For example (using _ to indicate a blank)
"254.01__________23.0001_________45.045609_______"
I get the 16-character units using the following function, where PS is assigned the numeric value:
Public Function PadStr(ToLen, PS)
ExistLen = Len(PS)
AddLen = ToLen - ExistLen
If AddLen > 0 Then
For n = 1 To AddLen
PS = PS & " "
Next n
End If
PadStr = PS
End Function
An example is PadStr(16,Me![calcium])
This function works fine BUT, it strips trailing 0s, and it strips the decimal point if the number is an integer value. For example:
250.010 is returned as "250.01__________" (number followed by 10 blanks) and
250.0 is returned as "250_____________"
IS THERE SOME WAY to prevent this stripping, to get:
"250.010_________" and
"250.0___________" ??
Last edited: