Results 1 to 2 of 2

Thread: Help a newbie

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2000
    Posts
    3

    Talking

    Experiencing few problems with new program:

    1. Search function. (trying to find a particular word in the text box and see how many times it appears.) haveing difficulty with the part where it calculates how many times the word is present.

    Private Sub cmdSearch_Click()
    Dim txtSearch As String

    txtSearch = InputBox$("Search for what?", "Search", "")
    If InStr(txtMain.Text, txtSearch) = 0 Then
    MsgBox "no match found", vbExclamation
    Else (part that calculates how many times the word is present)
    MsgBox "Text was found" & (#of times) & "times", vbInformation, "Search"
    End If
    End Sub


    2. The part that counts the number of words and number of sentances in a program, depending if the check boxes (count words) & (count sentances) are selected. Private Sub

    cmdAnalyze_Click()
    Select Case txtMain.Text
    Case Check1.Value = 1, Check2.Value = 1
    MsgBox "Your text contains: " & Chr$(10) & " words" & Chr$(10) & " sentences", vbInformation, "Analysis"
    Case Check1.Value = 1
    MsgBox "Your text contains: " & Chr$(10) & " words", vbInformation, "Analysis"
    Case Check2.Value = 1
    MsgBox "Your text contains: " & Chr$(10) & " sentences", vbInformation, "Analysis"
    End Select

    the problem is that I cant seem to get Check.value to work and I cant figure out how to actually check for the number of words and sentances.

    Thank you for the responses

    R2-D2 newbie vb programer
    End Sub


  2. #2
    Guest
    You used the Select Case method for txtMain.Text. Why is your Case Check1.Value = 1. That has nothing to do with txtMain.Text. txtMain.Text is a String. Check1.Value = 1 is a statement.

    You cannot have that. This of Select Case as sort of an If...Then statement.

    Code:
    ' Here is an If...Then statement 
    If txtMain.Text = "Hello" Then
         MsgBox ("Hello")
    End If
    
    '********************************
    '********************************
    
    ' Here is a Select Case statement
    Select Case txtMain.Text
         Case "Hello" 
            MsgBox ("Hello")
    End Select


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width