An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.
One of a set of tools we're offering as a way of saying thank you for being a part of the community.
1. Put a single command button on your, a little tiny one, with just the letter "A" on it. Put it exactly where you want the button to appear in the finished product. Set font, font size, bold, etc. for this "A" button, however you want all the buttons to look. The "A" button is the model for all 26 buttons. Call the button "cmdLetter" and set Index to 0, so it'll be considered an array by VB.
2. Now write this simple little function and call it from Form_Load, setting LETTER_SPACING to the distance you want between buttons:
Private Sub createLetterButtons_Click(
Const LETTER_SPACING As Integer = 100
Dim i As Integer
Dim leftPos As Integer
leftPos = cmdLetter(0).left
For i = 1 To 25
leftPos = leftPos + cmdLetter(0).width + LETTER_SPACING
Load cmdLetter(cmdLetter.UBound
With cmdLetter(cmdLetter.UBound
.Caption = Chr(i + 65)
.left = leftPos
.Visible = True
End With
Next i
End Sub
The command buttons will appear, all 26 of them, no problem. To respond to a user's selection of one of them, this is all you need:
Private Sub cmdLetter_Click(index As Integer)
MsgBox "You clicked: " & cmdLetter(index).Caption
End Sub