Portal:AOL-Files/Articles/VB to HTML: Difference between revisions

From NINA Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
{{AOL-Files}}
{{AOL-Files
 
|section=articles}}
(Originally by AOL-Files staff member Tau)
(Originally by AOL-Files staff member Tau)



Revision as of 03:00, 16 October 2020

 
AOL-Files Articles Downloads FDO91

(Originally by AOL-Files staff member Tau)

Purpose: I had to quickly make a program to color code the Visual Basic code on this site. Keep in mind this took me around 25 minutes to make so its not that great. But, enhance it all you choose.

Requirements: This code requires a Command Button named cmdConvert which can be modified in the last Sub.

Private Sub cmdConvert_Click()
Dim i%, StartSpot%, Spot%, vbCr1%
txtVB.Text = Replace(txtVB.Text, String(4, Chr(32)), " " & " " & " " & " ")
txtVB.Text = Replace(txtVB.Text, vbCrLf, "
" & vbCrLf)
For i = 0 To lstBlue.ListCount - 1
    DoEvents
    txtVB.Text = Replace(txtVB.Text, lstBlue.List(i), "" & lstBlue.List(i) & "")
Next i
StartSpot% = 0
Do: DoEvents
    Spot% = InStr(StartSpot% + 1, txtVB.Text, "'")
    If Spot% = 0 Then Exit Do
    vbCr1% = InStr(Spot% + 1, txtVB.Text, vbCrLf)
    If vbCr1% = 0 Then vbCr1% = Len(txtVB.Text)
    txtVB.Text = Left(txtVB.Text, Spot% - 1) & "" & Mid(txtVB.Text, Spot%, vbCr1% - Spot%) & "" & Mid(txtVB.Text, vbCr1%)
    StartSpot% = vbCr1%
Loop Until vbCr1% = Len(txtVB.Text)
End Sub

Private Sub Form_Load()
With lstBlue
    .AddItem "Option "
    .AddItem "Explicit"
    .AddItem "Private "
    .AddItem "Function"
    .AddItem "Public "
    .AddItem "For "
    .AddItem " To "
    .AddItem "Dim "
    .AddItem "If "
    .AddItem " Then"
    .AddItem "Exit "
    .AddItem "End"
    .AddItem "Sub"
    .AddItem "Next"
    .AddItem " String"
    .AddItem " Integer"
    .AddItem " Long"
    .AddItem "Public Const"
    .AddItem "Else"
    .AddItem " True"
    .AddItem "False"
    .AddItem "Do"
    .AddItem "Loop"
    .AddItem "Until"
    .AddItem "Call "
    .AddItem " And "
    .AddItem " Goto"
    .AddItem " Or "
    .AddItem "While "
    .AddItem "With "
    .AddItem "Public Declare Function"
    .AddItem "Private Declare Function"
    .AddItem " Alias "
    .AddItem " Lib "
    .AddItem "ByVal "
    .AddItem " ListBox"
    .AddItem "As Long"
    .AddItem "As String"
    .AddItem "As Integer"
    .AddItem ""
    .AddItem "Const"
    .AddItem " Declare "
End With
End Sub