|
-
June 14th, 2001, 09:37 AM
#1
Manipulating individual character's ASCII values
I was wondering if there's a command to manipulate the ascii value of specific characters in visual basic. It's a fairly simple process in other more complex languages.
The problem that I have is that I am making a curriculum for a summer camp teaching grade 6-8 students the basics of programming. The project I wanted to do was to write a simple encode/decode program in visual basic that the kids could create a windowed exe file they could execute at home but the best way I know how to encode a basic text message is to manipulate the ascii value. If there's any more project ideas out there or another way to encode that would be welcome as well as letting me know if there is a way to maniuplate character ascii values.
-
June 14th, 2001, 10:06 AM
#2
Re: Manipulating individual character's ASCII values
It's fairly simple in VB too. Just assign the string to a byte array. You process every other byte (Each character requires two bytes in Unicode).
As an example, here is an example from one of my earlier posts that checks whether a character is alphabetic or not. You can modify it to suit you.
Code:
Private Function isalpha(str as string) as Boolean
Dim ByteArr() as Byte
Dim i as Integer
Dim AllAlpha as Boolean
ByteArr = str
AllAlpha = true
for i = 0 to UBound(ByteArr) step 2
If Not (((ByteArr(i) >= 65) And (ByteArr(i) <= 90)) Or ((ByteArr(i) >= 97) And (ByteArr(i) <= 122))) then
AllAlpha = false
Exit for
End If
next
isalpha = AllAlpha
End Function
Private Sub Command1_Click()
MsgBox isalpha("Hello")
End Sub
Last edited by Cimperiali; March 16th, 2005 at 03:35 PM.
Reason: adding code tags
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|