Option Explicit
Private Sub txtInput_Change()
' paste all class header variable declarations in Input textbox
' copy text in Output textboxes to bottom of class
' call function when you need to know
' Example: paste to Input textbox
'
' 'local variable(s) to hold property value(s)
' Private mvarLineContent As String 'local copy
' 'local variable(s) to hold property value(s)
' Private mvarEntryDate As String 'local copy
' 'local variable(s) to hold property value(s)
' Private mvarEntryTime As String 'local copy
'
' Ouptut textbox will contain:
'
' Public Function ShowAll()
' ' For debugging. shows values of all variables in class instance
' ' SYNTAX: in class instance: [instanceName].ShowAll
' ' SYNTAX: in collection of class instance: [collectionName].([index])ShowAll
' '
' ' Author: Robert Budzynowski
'
' Debug.Print "LineContent = {" & mvarLineContent & "}"
' Debug.Print "EntryDate = {" & mvarEntryDate & "}"
' Debug.Print "EntryTime = {" & mvarEntryTime & "}"
'
' End Function
Dim lines() As String
Dim x As Integer
Dim mvarLoc As Integer
Dim SpaceLoc As Integer
Dim classVarName As String
Dim varName As String
Dim trimmedLine As String
Dim processInput As Boolean
' no point if no class header data
mvarLoc = InStr(UCase(txtInput.Text), "MVAR")
If mvarLoc = 0 Then
MsgBox "Text entered does not contain class header data", vbOKOnly, "Input Error"
' clear existing output text
txtOuput.Text = ""
' highlight text
txtInput.SelStart = 0
txtInput.SelLength = Len(txtInput.Text)
txtInput.SetFocus
End If
' function header & description
txtOuput = "Public Function ShowAll()" & vbCrLf
txtOuput = txtOuput & " ' For debugging. shows values of all variables in class instance" & vbCrLf
txtOuput = txtOuput & " ' SYNTAX: in class instance: [instanceName].ShowAll" & vbCrLf
txtOuput = txtOuput & " ' SYNTAX: in collection of class instance: [collectionName].([index])ShowAll" & vbCrLf
' please give credit where credit is due!
txtOuput = txtOuput & " ' " & vbCrLf
txtOuput = txtOuput & " ' Author: Robert Budzynowski" & vbCrLf
txtOuput = txtOuput & vbCrLf
' create array element for each line in input textbox
lines = Split(txtOuput.Text, vbCrLf)
' process each line of input textbox
For x = 0 To UBound(lines)
' check for "mvar" text is line, if so we work with it
mvarLoc = InStr(UCase(lines(x)), "MVAR")
If mvarLoc > 0 Then
' valid line. Trim everything prior to start of var name (usually "Private ")
trimmedLine = Right(lines(x), Len(lines(x)) - mvarLoc + 1)
' find the space after the var name
SpaceLoc = InStr(trimmedLine, " ")
' the modular var name is before the space
classVarName = Trim(Left(trimmedLine, SpaceLoc))
' get the var name without the mvar prefix
varName = Right(classVarName, Len(classVarName) - Len("mvar"))
' this is the line you want
txtOuput = txtOuput & vbTab & "Debug.Print " & Chr(34) & varName & " = {" & Chr(34) & " & " & classVarName & " & " & Chr(34) & "}" & Chr(34) & " " & vbCrLf
End If
Next x
' finish function text
txtOuput = txtOuput & vbCrLf
txtOuput = txtOuput & "End Function"
End Sub
Private Sub cmdClearTextBoxes_Click()
' clear textboxes
txtInput.Text = ""
txtOuput.Text = ""
End Sub
Private Sub cmdCopyToClipboard_Click()
' copy output text
Clipboard.Clear
Clipboard.SetText txtOuput.Text
End Sub
End Sub