theservant,
Put invisible Label1(0) label on your form below your formula txtFormula text box and leave enough space (sufficient for several labels) below that label.
Put Command button at the bottom of the form and copy this code:
Option Explicit
Private Sub Command1_Click()
Dim strTemplate As String
Dim intIndex As Integer
Dim intNumberOfLabels As Integer
Dim strElements() As String
Dim objLabel As Control
For Each objLabel In Me.Controls
If TypeName(objLabel) = "Label" Then
If objLabel.Index > 0 Then
Unload objLabel
End If
End If
Next objLabel
strTemplate = txtFormula.Text
strTemplate = Replace(strTemplate, "+", "@", , , vbBinaryCompare)
strTemplate = Replace(strTemplate, "-", "@", , , vbBinaryCompare)
strTemplate = Replace(strTemplate, "*", "@", , , vbBinaryCompare)
strTemplate = Replace(strTemplate, "/", "@", , , vbBinaryCompare)
strElements = Split(strTemplate, "@", , vbBinaryCompare)
intNumberOfLabels = UBound(strElements)
If intNumberOfLabels > -1 Then
Label1(0).Caption = strElements(0)
Label1(0).Visible = True
For intIndex = 1 To intNumberOfLabels
Load Label1(intIndex)
Label1(intIndex).Left = Label1(intIndex).Left
Label1(intIndex).Top = Label1(intIndex - 1).Top + Label1(intIndex - 1).Height + 100
Label1(intIndex).Caption = strElements(intIndex)
Label1(intIndex).Visible = True
Next intIndex
End If
End Sub
Private Sub Form_Load()
txtFormula.Text = "ac123+af221*3-ag001"
End Sub
vladk