Results 1 to 2 of 2

Thread: Displaying in a label

  1. #1
    antma
    Guest

    Angry Displaying in a label

    hi there

    Im Currently busy creating hangman But stuck with a little problem

    I have a label which displays the secret word in "********" astrics.


    now I have managed 2 get the letters chosen to be able to display in the label.

    My question is what the heck am I doing wrong..


    Eg of the coding so far
    For i = 1 To Len(NewWord)
    If TxtGuess.Text = UCase(Mid(NewWord, i, 1)) Then

    LblWord.Caption = UCase(Mid$(LblWord.Caption, 1, i) & Mid$(NewWord, i, 1) & Mid$(LblWord.Caption, i + 1))
    'LblWord.Caption = LblWord.Caption & NewWord & "*"

    Correct = True
    End If

    Next i

    It is spose 2 built the caption to say Eg : *A* ..Say the word
    was "MAN"

    Please help

  2. #2
    PowerPoster Arbiter's Avatar
    Join Date
    Sep 2000
    Location
    Manchester
    Posts
    2,276
    Okey dokey, I gotta little something for ya here.

    Firstly, I'm working on the premise that there is and 'actualword' (the word they're trying to guess) and 'guesses' which a string of all the letters they've picked so far.

    Every time the user guesses a letter, append it to the end of 'guesses'.

    Then simply call the following sub

    Code:
    Sub UpdateProgress()
        Dim i As Integer, SelectedLetter As String
        
        For i = 1 To Len(actualword)
            SelectedLetter = Mid$(actualword, i, 1)
            If InStr(1, guesses, SelectedLetter) > 0 Then
                lblword.Caption = lblword.Caption & SelectedLetter
            Else
                lblword.Caption = lblword.Caption & "*"
            End If
        Next i
        
    End Sub
    I don't have VB at work, so there may be syntax errors in the above, but I'm sure you can sort them out.

    Hope that helps...
    Gentile or Jew,
    O you who turn the wheel and look to windward,
    Consider Phlebas, who was once handsome and tall as you...

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