Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Beginning VB 6
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Beginning VB 6 For 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 .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old March 30th, 2007, 12:12 AM
Registered User
 
Join Date: Mar 2007
Location: Howrah, WB, India.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Converting a set of string to its ascii value...


Hi friends,:)

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.

Please any one can help me?
Thanks in advance.
                                                                     -- Rittwick Banerjee
                                                               rittwickbanerjee@gmail.com
__________________
Rittwick Banerjee
Reply With Quote
  #2 (permalink)  
Old March 30th, 2007, 09:44 AM
Friend of Wrox
 
Join Date: Nov 2004
Location: Port Orchard, WA, USA.
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

It converts only the first character...

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...
Reply With Quote
  #3 (permalink)  
Old March 30th, 2007, 09:53 AM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,190
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

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
================================================== =========
Reply With Quote
  #4 (permalink)  
Old March 30th, 2007, 09:42 PM
Registered User
 
Join Date: Mar 2007
Location: Howrah, WB, India.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.

                                                                     -- Rittwick Banerjee
                                                               rittwickbanerjee@gmail.com
Reply With Quote
  #5 (permalink)  
Old April 2nd, 2007, 10:46 AM
Friend of Wrox
 
Join Date: Nov 2004
Location: Port Orchard, WA, USA.
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

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.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting String into Node-set dved XSLT 3 January 23rd, 2008 11:40 AM
Converting Int -> ASCII silaros C++ Programming 1 June 5th, 2007 01:12 AM
Converting an ASCII character to binary? skyraider Visual Basic 2005 Basics 0 May 7th, 2006 08:20 PM
Return ASCII values for a given string sal C# 1 May 19th, 2005 03:59 PM
Converting a string to an expression Nick.Net VB.NET 2002/2003 Basics 1 March 5th, 2004 08:41 PM



All times are GMT -4. The time now is 05:51 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.