- Home
·
- String Manipulation
·
- This function is very usefull for Hangmand type games, where you replace a blank character (like an
This function is very usefull for Hangmand type games, where you replace a blank character (like an
This function is very usefull for Hangmand type games, where you replace a blank character (like and asterisk * or hyphen - ), with a letter.
Rate This function is very usefull for Hangmand type games, where you replace a blank character (like an
(1(1 Vote))
'This function will find all occurrences of a letter
'in a word and replace the corresponding character
'in the other word, with the letter.
'eg. AddLetter("Hello","**ll*","E")
'returnes; "*ell*"
Dim Counter As Integer
Dim LetterPos As Integer
'if the first two parameters are not the same length
'then exit function
If (Len(ActualWord) <> Len(DisWord)) Or (Len(Letter) > 1) Then
'exit
AddLetter = "Error"
Exit Function
End If
Letter = LCase(Letter)
For Counter = 1 To Len(ActualWord)
LetterPos = InStr(Counter, LCase(ActualWord), Letter)
'if the letter was found past the current
'position, then
If LetterPos >= Counter Then
'display the letter in the returned value
DisWord = Left(DisWord, LetterPos - 1) & Mid(ActualWord, LetterPos, 1) & Right(DisWord, (Len(ActualWord) - LetterPos))
Counter = LetterPos
End If
Next
AddLetter = DisWord
End Function
This function is very usefull for Hangmand type games, where you replace a blank character (like an Comments
No comments yet — be the first to post one!
Post a Comment