phweston
Programmer
- May 8, 2003
- 38
For starters, we have this code in SQL. We are trying to convert this to Access VBA.
The purpose of the funciton is to scramble names to make this unreadble.
The function will convert a name by taking each character and moving it up one in the alphabet. For example A would becomie B in the string, B would become C, and so on. the letter Z would become A.
For example: Bob would be turned into Cpc.
Here is the code in Access:
Public Function ScrambleName(str)
Dim CharIndex As Integer
Dim Strafter As String
Dim CharBefore As String
Dim CharAfter As String
CharIndex = 1
Strafter = " "
While (CharIndex <= Len(str))
CharBefore = String(str, CharIndex)
CharIndex = CharIndex + 1
If ((CharBefore) >= "a" And (CharBefore) < "z" Or (CharBefore) >= ("A") And (CharBefore) < ("Z")) Then
CharAfter = ((CharBefore) + 1)
ElseIf (CharBefore) = ("z") Then
CharAfter = ("a")
ElseIf (CharBefore) = "Z" Then
CharAfter = "A"
Else
CharAfter = CharBefore
End
Strafter = Strafter + CharAfter
End
End If
Wend
End Function
The purpose of the funciton is to scramble names to make this unreadble.
The function will convert a name by taking each character and moving it up one in the alphabet. For example A would becomie B in the string, B would become C, and so on. the letter Z would become A.
For example: Bob would be turned into Cpc.
Here is the code in Access:
Public Function ScrambleName(str)
Dim CharIndex As Integer
Dim Strafter As String
Dim CharBefore As String
Dim CharAfter As String
CharIndex = 1
Strafter = " "
While (CharIndex <= Len(str))
CharBefore = String(str, CharIndex)
CharIndex = CharIndex + 1
If ((CharBefore) >= "a" And (CharBefore) < "z" Or (CharBefore) >= ("A") And (CharBefore) < ("Z")) Then
CharAfter = ((CharBefore) + 1)
ElseIf (CharBefore) = ("z") Then
CharAfter = ("a")
ElseIf (CharBefore) = "Z" Then
CharAfter = "A"
Else
CharAfter = CharBefore
End
Strafter = Strafter + CharAfter
End
End If
Wend
End Function