[RESOLVED] Is it possible to hide some letters inside a label caption, but not all of them?-VBForums
Results 1 to 6 of 6

Thread: [RESOLVED] Is it possible to hide some letters inside a label caption, but not all of them?

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Posts
    2,270

    Resolved [RESOLVED] Is it possible to hide some letters inside a label caption, but not all of them?

    Hi there folks! I am working on a "figure out the missing word" game for Kindergarten students. What I would like to do is have a word in a label caption (and I have that) The words could be anywhere from 2 letters long to 8 letters. What I am trying to figure out is how to replace random letters in the caption with blank spaces or underscores, leaving only 1 letter showing.

    I've used replace in the past, but only when replacing 1 specific characters with another specific character.

    Would anyone know of an idea for this?

    Thanks a lot!

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    16,638

    Re: Is it possible to hide some letters inside a label caption, but not all of them?

    I'd suggest using a separate string variable, modifying it as needed, then reassign that variable to the label's Caption property. You can change an individual letter in a string variable using Mid$(), i.e., change the 5th character to an underscore:
    Code:
    Mid$(strCaption, 5, 1) = "_"
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    6,294

    Re: Is it possible to hide some letters inside a label caption, but not all of them?

    An alternative to a label is to use an array of textboxes.

    See the attached example where once you 'load' the word (I only load one: "TEACHER"), you click on any of the textboxes to show the first letter...then if the student doesn't guess correctly, click on another one...until the answer is completely shown.

    Anyway, just another approach.
    Attached Files Attached Files

  4. #4
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    12,154

    Re: Is it possible to hide some letters inside a label caption, but not all of them?

    If you want to leave only one character visible and still remember the original you can simply set the caption to all underscores or whatever character you want to use.
    You have your real string stored in a variable or if you want the tag of the label.

    You would then use a combination of Rnd() and Len() to get a random character from your string and the Mid$ statement to place that character into the correct position of the label leaving all the others as underscores.

  5. #5
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    6,294

    Re: Is it possible to hide some letters inside a label caption, but not all of them?

    Morning, Justin...

    Just for fun, I made a 'few' changes to the program I attached yesterday. Let's you show a form to the kids while you work on the main form, selecting the words (you'd need a second monitor to display the second form).

    Anyway, it uses an array of textboxes, randomize (non-repeating random numbers) and a second form.

    You might adapt this if you want.

    Sam
    Attached Files Attached Files

  6. #6

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Posts
    2,270

    Re: Is it possible to hide some letters inside a label caption, but not all of them?

    Awesome awesome stuff! Thank you all for your help!

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.