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!

trimming txtbox entries

Status
Not open for further replies.

Jay2003

Programmer
Feb 26, 2003
147
GB
Hi,

Is it possible to get a user to enter a password into a txtbox, then trim the ascii by a certain amount, after this then compare against a database version of the password for access.

Thanks in advance for any help.

Jason
 
When you say trim - do you mean chopping off characters to force the string to a fixed length.

eg)
mypassword1 becomes [red]mypass[/red]
yourpassword1 becomes [red]yourpa[/red]

If so you can use...
Code:
strText = Request.Form("password")
strText = Left(strText,6)


Tony
_______________________________________________________________
 
no, Say I have an entry of pass, I want to trim or convert each letter to an ascii value, Like a quick encryption.

Jason
 
Did you want to do this client-side or server-side? If client-side, I'd recommend Javascript.

Lee
 
Er...like the Asc() function to convert a letter to it's ASCII numeric equivalent? Or were you looking for a conversion to Hex...?

Code:
<%
Dim a
a = "MyPassword"

Response.Write "original string: " & a & "<br>"
Response.Write "0-filled numeric string: " & strToAsc(a) & "<br>"
Response.Write "Hex string: " & strToAscHex(a) & "<br>"

Function strToAsc(str)
	Dim i
	For i = 1 to Len(str)
		strToAsc = strToAsc & ZeroFill(Asc(mid(str,i,1)),3)
	Next
End Function

Function strToAscHex(str)
	Dim i
	For i = 1 to Len(str)
		strToAscHex = strToAscHex & ZeroFill(Hex(Asc(mid(str,i,1))),2)
	Next
End Function

Function ZeroFill(str, numChars)
	ZeroFill = str
	If numChars > len(str) Then ZeroFill = string(numChars - len(str),"0") & str
End Function

%>

If you want more extnsive base-conversion scripts, look around the searchj. Somewhere in this forum I posted my base-n conversion function that converts to anything from base-2 to base 36-ish

-T

barcode_1.gif
 
Ok, Now I have the ascii value how can I trim this by say minus 3 or basically convert the string passed to an ascii value of minus 3.

Thanks

Jason
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top