- Home
·
- String Manipulation
·
- This is a filipino game, its task is to count every same letters of two strings, then use the sum t
This is a filipino game, its task is to count every same letters of two strings, then use the sum t
This is a filipino game, its task is to count every same letters of two strings, then use the sum to count through the word "FLAMES". Every
Rate This is a filipino game, its task is to count every same letters of two strings, then use the sum t
(1(1 Vote))
add 1 command box name it cmdflames
'code:
Option Explicit
Private Sub cmdFlames_Click()
Dim intResult As Integer
Dim strFlames As String
Dim strCurrentLetter As String
Dim dblStart As Double
dblStart = 1
strFlames = "FLAMES"
If txtFirstName.Text <> "" And txtSecondName.Text <> "" Then
intResult = Flames(txtFirstName.Text, txtSecondName.Text)
End If
Do
strCurrentLetter = Mid(strFlames, dblStart, 1)
dblStart = dblStart + 1
Loop Until dblStart = intResult + 1
Select Case strCurrentLetter
Case "F"
MsgBox "Friends"
Case "L"
MsgBox "Lovers"
Case "A"
MsgBox "Admirer"
Case "M"
MsgBox "Mutual Understanding"
Case "E"
MsgBox "Enemy"
Case Else
MsgBox "Secret Lovers"
End Select
End Sub
Private Function Flames(strFirstName As String, strSecondName As String)
Dim strLetterOfFirstName As String
Dim strLetterOfSecondName As String
Dim intStartOfFirstName As Double
Dim intStartOfSecondName As Double
Dim intResult As Integer
Dim intFinalResult As Double
intStartOfFirstName = 1
intStartOfSecondName = 1
Do
strLetterOfFirstName = Mid(strFirstName, intStartOfFirstName, 1)
Do
strLetterOfSecondName = Mid(strSecondName, intStartOfSecondName, 1)
intResult = InStr(1, strLetterOfFirstName, strLetterOfSecondName)
intFinalResult = intFinalResult + intResult
If strLetterOfSecondName = " " And intResult = 1 Then
intFinalResult = intFinalResult - 1
End If
intStartOfSecondName = intStartOfSecondName + 1
intResult = 0
Loop Until intStartOfSecondName = Len(strSecondName) + 1
intStartOfFirstName = intStartOfFirstName + 1
intStartOfSecondName = 1
Loop Until intStartOfFirstName = Len(strFirstName) + 1
Flames = intFinalResult
End Function
This is a filipino game, its task is to count every same letters of two strings, then use the sum t Comments
No comments yet — be the first to post one!
Post a Comment