Link to home
Start Free TrialLog in
Avatar of Thomas_Meyer
Thomas_MeyerFlag for Czechia

asked on

How to the macro that divides the letters of a word?

Hi Experts,
 I need help with adding macros to test for historical knowledge.
 I separated the whole complexity of the 2 questions.
 My example of the folding of the four questions that the user will guess the answer.
 Because the task of student letters will guess, I need to go into the macro simply write the correct answer (see BARBAROSSA, PREMYSLID etc.). The main task of the macro to show the many shapes ("letter1" to "letter12"), how much is currently needed.
Example: "BARBAROSSA" word has 10 characters, so the macro displays the 10 rectangles (from "letter1" to "letter10").
"CAPETIAN" word has 8 characters, so the macro displays the 8 rectangles (from "letter1" to "letter8").
The macro should always be run by clicking on CommandButton1
Note: never guess the word is longer than 12 characters.
Thank you in advance for any help.
Regards,
TM
Test-history.ppt
Avatar of Thomas_Meyer
Thomas_Meyer
Flag of Czechia image

ASKER

I think it will be done using function "Len".
Avatar of GrahamSkan
Hello Thomas,

It wasn't very clear where you were stuck. I started to write some code to place the boxes with the letters in, which was taking some time. However if all you need is to extract the letters individually, then 'Len' will certainly be necessary. This will put the letters into an array.

Dim i as Integer
Dim strLetters() as String
Dim strWord as String

strWord = "BARBAROSSA"

ReDim strLetters(Len(strWord) - 1)

For i = 0 to Len(strWord)
      strLetters(i) = Mid(strWord, i + 1, 1)
Next i

Open in new window

Oops. There is an error in line 9. It should be:

For i = 0 to Len(strWord) - 1
ASKER CERTIFIED SOLUTION
Avatar of Chris Bottomley
Chris Bottomley
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I did add my file but it didn't take.

I re-ordered the first two boxes letter1 and letter 2 as they were out of order, and I blanked everything so it starts out with a requirement to click the button.  The button event calls the test sub and from that point forward cycles through the questions and renders unwanted text boxes as invisible.

Hopefully that is what you were after for your first stage.

Chris
Perfect, magnificent work! I tried it on himself, but I had such a success;-)
The first part of this is done, write the second part of EE.
Chris, thank you very much.
Best Regards,
TM.