VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



This is a filipino game, its task is to count every same letters of two strings, then use the sum t

by moongeun (1 Submission)
Category: String Manipulation
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Fri 11th December 2009
Date Added: Mon 8th February 2021
Rating: (1 Votes)

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




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

Download this snippet    Add to My Saved Code

This is a filipino game, its task is to count every same letters of two strings, then use the sum t Comments

No comments have been posted about This is a filipino game, its task is to count every same letters of two strings, then use the sum t. Why not be the first to post a comment about This is a filipino game, its task is to count every same letters of two strings, then use the sum t.

Post your comment

Subject:
Message:
0/1000 characters