|
-
Nov 29th, 2000, 05:22 PM
#1
Thread Starter
New Member
how do i get the first letter out of a string?
-
Nov 29th, 2000, 05:27 PM
#2
Lively Member
Code:
strTmp = "Blah Blah"
'Cut the 1st B
strTmp = Mid$(strTmp,2)
-
Nov 29th, 2000, 05:28 PM
#3
Fanatic Member
Code:
Dim str As String
Dim sFirstChar As String
str = "Hello"
sFirstChar = Left(Trim(str), 1) ' returns "H"
str = " HELLO"
sFirstChar = Left(Trim(str), 1) 'returns "H"
Remove the Trim statement if you want to return a space
{Insert random techno-babble here}
{Insert quote from some long gone mofo here}
-
Nov 29th, 2000, 05:50 PM
#4
Thread Starter
New Member
what i am trying to do is take the first letter and take the ascii value for it and add one to it then put it back into the string and do the same for the rest of the characters and also beable to reverse is to get it back to normal
-
Nov 29th, 2000, 06:06 PM
#5
Fanatic Member
This should do the trick
Code:
Private Sub Form_Load()
Dim s As String
s = "abcdefghijklmno"
' raise characters ascii value by 1
s = UpOneString(s)
Debug.Print s
' lower characters ascii value by 1
s = DownOneString(s)
Debug.Print s
End Sub
Public Function UpOneString(s As String) As String
Dim iPos As Integer
Dim strOut As String
Dim sChar As String
Dim iAscVal As Integer
For iPos = 1 To Len(s)
' get current character
sChar = Mid(s, iPos, iPos + 1)
' get characters ascii value + 1
iAscVal = (Asc(sChar) + 1)
' if ascii value is out of range then wrap around to first character
If iAscVal > 255 Then iAscVal = 0
' change character to new value
sChar = Chr(iAscVal)
' add to string to be returned by function
strOut = strOut & sChar
Next iPos
' return string
UpOneString = strOut
End Function
Public Function DownOneString(s As String) As String
Dim iPos As Integer
Dim strOut As String
Dim sChar As String
Dim iAscVal As Integer
For iPos = 1 To Len(s)
' get current character
sChar = Mid(s, iPos, iPos + 1)
' get characters ascii value - 1
iAscVal = (Asc(sChar) - 1)
' if ascii value if out of range than wrap around to last character value
If iAscVal < 0 Then iAscVal = 255
' change character to new value
sChar = Chr(iAscVal)
' add to string to be returned by function
strOut = strOut & sChar
Next iPos
' return string
DownOneString = strOut
End Function
{Insert random techno-babble here}
{Insert quote from some long gone mofo here}
-
Nov 30th, 2000, 12:57 AM
#6
PowerPoster
Encryption
You sopund like wish to write a simple data encryption routine rite?
Here is the code that will add a eKey value into the source string.
[code]
Private Sub Command1_Click()
Dim i As Integer
Dim x As Integer
Dim eStr As String
Dim eKey As Integer
Dim tmp As String
'Save the encryption key
eKey = CInt(Text2)
'Save the source string
tmp = Text1
For i = 1 To Len(tmp)
'Get the first string ASCII value
x = Asc(tmp)
'Add the key value into the source string
x = x + CInt(eKey)
'Check for > 255
Do While x > 255
x = x - 256
DoEvents
Loop
eStr = eStr & Chr(x)
tmp = Mid(tmp, 2)
Next
MsgBox eStr
End Sub
[code]
-
Nov 30th, 2000, 07:46 AM
#7
Frenzied Member
If you're making that kindof encryption, be warned, even my dog is able to figure out how that's done, and you know, he isn't even that smart 
look at kedaman's site for a cool encryption method ( http://www.kedaman.com )
hey keda, you really should ship me that money by now 
Have fun.
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
-
Nov 30th, 2000, 07:50 PM
#8
PowerPoster
Hi! Job,
In my encryption I only applied 1 encryption key, for more security you can have more than 1 encryption key. Yet, this key not limited to integer, you can have some kind of string. But if you cool encryption I thing the Crytography SDK will be the most coolest.
As a result, you can have ?? million of combination output. In my point of view, in this world there is nothing so call secure. Nothing is perfect... yet there still have somebody call himself as cracker to crack your encrypted data.
-
Dec 2nd, 2000, 02:25 AM
#9
Thread Starter
New Member
Thanks all. all i needed to do is have it so the average joe could not edit lock info in a text save file (ex: the STATS on a character) with out have knowldge of programing
thanks for your help
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
|