Question: characters and writing to a text file

C

cyb3rwolf

I am using Access 2007. This is kind of weird, but this is what i'm trying
to do: I have a form where i want to to take each character entered in a
text field and then look up information with that character's ascii code in a
table. For example if i had "testing" in a text box, i want it to first look
up the "t" then the "e" then the "s," etc. (including spaces as well.) In my
table i have 2 fields: "ASCII" and "Output." I want it to look up the
corresponding "Output" and then take that value and append it to a text file.
Hopefully i explained this clearly enough. Anybody help me out or point me
in the right direction?
 
M

Mr. B

cyb3rwolf,

Here is the entire code from a commad button named: "cmdGetValues":

Private Sub cmdGetValues_Click()
Dim strInputVal As String
Dim strOutputVal As String
Dim strChar As String
Dim intAsciVal As Integer

strInputVal = Me.NameOfYourInputTextBox
For cntr = 1 To Len(strInputVal)
'read each character
strChar = Mid(strInputVal, cntr, 1)
varAsciVal = Asc(strChar)
'get the Output value from the table
intAsciVal = strOutputVal & DLookup("Output", _
"tblTableName", "ASCII = " & intAsciVal & "")
Next cntr
'to add the value stored in the strOutputVal variable to a text file
' see comment and link below
End Sub

For help with creating and writing to a text file, see the following link:

http://groups.google.com/group/micr...f3?lnk=gst&q=open+for+output#bd0376526724e4f3
 
C

cyb3rwolf

Thank you so much for the help. This seems to work for everything i need
except if there is a space. This causes errors. Anybody able to help me out
with this last detail?
 
M

Mr. B

What happens when you have a space? The ASCII code for a space is 192.

That is the value that should be in the "varAsciVal" variable.

Do you have a record in your "Output" table for 192?
 
C

cyb3rwolf

Actually, i got it figured out. I was trying to test it and ONLY had a space
in the field, and that caused an error. This is no big deal, there would
never be a reason where the would be just a space in the text box once this
form is used. it returns the spaces ascii code (however it returns 32, not
192, for the ascii value). This part now works just fine, i came across a
different problem with the way it is outputting to a text file, it puts
quotes at the beginning and end of each line inserted into the text file. I
posted this question as a different thread. Thanks so much for your help!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top