Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stuck 2

Status
Not open for further replies.

Manic

Programmer
Feb 28, 2001
343
GB
I am saving details captured in a form.

What I want to do is add numbers to some of the numeric data so that there will always be a fixed number of characters there.

Any idea ?? Cause I can't find anything.

Manic
 
Check the length of the posted field and then add as many characters as you want...
Example:

wantedlength=6
length=len(postedfield)
If length<wantedlength Then
' If IsNumeric(postedfield) Then
addstr=string(wantedlength-length, &quot;0&quot;)
postedfield=addstr & postedfiel
' End If
End If

if the postedfield was 123 then the output would be 000123, I hope.

Why do you want to do this? It sounds strange...

 
it is for a database of customer information.

it will need to reas 12300000000000000

or something similar

Thanks for the help

Manic -----------------------------
I've broken it again !!
-----------------------------
 
I have got the bit of code working but I either get the zeros or the data from the form. My brain is a bit fried today. Any ideas ??

This is the code I am using

<%

Dim fileSys
Dim textStr
Dim FileName
Set fileSys = Server.CreateObject (&quot;Scripting.FileSystemObject&quot;)

Const saveFolder = &quot;C:\Inetpub\ saveFile = &quot;BACSau.txt&quot;

If (NOT fileSys.FolderExists(saveFolder)) Then
fileSys.CreateFolder saveFolder
End If

wantedlength=25
length=len(CCNumber)
If length<wantedlength Then
' If IsNumeric(CCNumber) Then
addstr=string(wantedlength-length, &quot;0&quot;)
CCNumber= CCNumber & addstr
' End If
End If


Set textStr = fileSys.OpenTextFile(saveFolder+saveFile, 8, true)

textStr.WriteLine CCNumber & Request.Form(&quot;CardName&quot;) & Request.Form(&quot;Sortcode&quot;)
textStr.Close

Set fileSys = Nothing
Set textStr = Nothing
%> -----------------------------
I've broken it again !!
-----------------------------
 
Maybe you did forget a CCNumber = Request.Form(&quot;CCNumber&quot;) ?

Also I recommend that you use response.write during debugging instead of writing to a file.
 
thanks -----------------------------
I've broken it again !!
-----------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top