Beginning VB 6For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
I am new to this forum. I am trying to make a program that takes some strings like ABCD and converts to its ascii value.
for example :
ABCD = string value
65666768 = ascii value
but ths problem is that when I am trying to convert the string value to ascii value by using vba.asc(string) it only takes the first string, not rest of those strings.
Now I want to make that app like this :
2 textboxes, 1 command button
If you type some text in the first text box and press that command button it will process all the string to their ascii value and shows the ascii value in second text box.
ASC() returns the value of one character. It disregards the rest. So you will have to write the code to pass one character at a time, and keep track of the values received, also one at a time.
Code:
Dim s As String
Dim i As Integer
s = "ABCD"
For i = 1 to Len(s)
<catch your value here> = ASC(Mid$(s, i, 1))
Next i
But what to do with the value is up to you. Myself, I can see no value to doing something like this. The result is altogether meaningless...
What are you trying to accomplish? I'm quite sure there's a better way...
in fact, be aware that the asc of every char can be 2 or 3 numbers!! so you will had a very hard time to retrieve the original string from there..
if you need to recover the original, add a format to 3 position for every ascii so you will know that every char has 3 positions...
HTH
Gonzalo
================================================== =========
Read this if you want to know how to get a correct reply for your question: http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
Hi,
BrianWren
You said that you found this meaningless, but I will tell you that what its meaning.
In fact I was trying to make app which require a license renewal after every 15 days, I wanted to store the serial number and some other useful information in Registry in their Ascii value with a encrypted format, thus a user or cracker can't break it. That is why I posted that problem which you found meaningless.
OK then. So your concept was a valid one. Just as creating it seemed to not fit any use, coming across it in the Registry would have had no meaning.
If it were me though, I would look for a program-specific way to make it unreadable.
You could:
Start at each end and take the 1st, last, 2nd, 2nd to last, 3rd characters and join them into a new string, and store that. So "Hello There" would become "HehrlelhoT "
You could set up a pure substitution. H = 3, e = z, l = b, r = g, T = u, o = x, Spc() = p, h = t
"Hello There" would become "3zbbxputzgz"
You could use an XOR cipher with a long key contained within the .exe. If the key is long enough there is no repeating at the beginning of the key, so pattern matching is 100% impossible.
You could store the actual data in a secure file, and just put data in the Registry that allows you to find the datum in the secure file.