Skip to content

Commit 66ae6ae

Browse files
authored
Merge pull request #938 from DecimalTurn/vb
Adjustments for the Visual Basic family of languages
2 parents 403bb05 + 5ac63b1 commit 66ae6ae

File tree

16 files changed

+247
-60
lines changed

16 files changed

+247
-60
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1359,14 +1359,14 @@ USS (uss)
13591359
UXML (uxml)
13601360
Vala (vala)
13611361
Vala Header (vapi)
1362-
VB for Applications (VBA, vba)
1362+
VBA (VBA, vba)
13631363
Velocity Template Language (vm)
13641364
Verilog-SystemVerilog (sv, svh, v)
13651365
VHDL (VHD, vhd, VHDL, vhdl, vhf, vhi, vho, vhs, vht, vhw)
13661366
vim script (vim)
1367-
Visual Basic (BAS, bas, ctl, dsr, frm, FRX, frx, VBHTML, vbhtml, vbp, vbw, cls)
1368-
Visual Basic .NET (VB, vb, vbproj)
1369-
Visual Basic Script (VBS, vbs)
1367+
Visual Basic (BAS, bas, ctl, dsr, Dsr, frm, FRX, frx, vbp, vbw, cls)
1368+
Visual Basic .NET (VB, vb, vbproj, vbhtml, VBHTML)
1369+
VBScript (VBS, vbs)
13701370
Visual Fox Pro (SCA, sca)
13711371
Visual Studio Solution (sln)
13721372
Visualforce Component (component)

Unix/cloc

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9616,17 +9616,18 @@ sub set_constants { # {{{1
96169616
'BAS' => 'Visual Basic' ,
96179617
'ctl' => 'Visual Basic' ,
96189618
'dsr' => 'Visual Basic' ,
9619+
'Dsr' => 'Visual Basic' ,
96199620
'frm' => 'Visual Basic' ,
96209621
'frx' => 'Visual Basic' ,
96219622
'FRX' => 'Visual Basic' ,
9622-
'vba' => 'VB for Applications' ,
9623-
'VBA' => 'VB for Applications' ,
9624-
'vbhtml' => 'Visual Basic' ,
9625-
'VBHTML' => 'Visual Basic' ,
9623+
'vba' => 'VBA' ,
9624+
'VBA' => 'VBA' ,
9625+
'vbhtml' => 'Visual Basic .NET' ,
9626+
'VBHTML' => 'Visual Basic .NET' ,
96269627
'vbproj' => 'Visual Basic .NET' ,
96279628
'vbp' => 'Visual Basic' , # .vbp - autogenerated
9628-
'vbs' => 'Visual Basic Script' ,
9629-
'VBS' => 'Visual Basic Script' ,
9629+
'vbs' => 'VBScript' ,
9630+
'VBS' => 'VBScript' ,
96309631
'vb' => 'Visual Basic .NET' ,
96319632
'VB' => 'Visual Basic .NET' ,
96329633
'vbw' => 'Visual Basic' , # .vbw - autogenerated
@@ -11484,7 +11485,7 @@ sub set_constants { # {{{1
1148411485
[ 'remove_matches' , '^\s*"' ],
1148511486
[ 'remove_inline' , '".*$' ],
1148611487
],
11487-
'Visual Basic Script' => [
11488+
'VBScript' => [
1148811489
[ 'remove_above' , '^\s*Attribute\s+VB_Name\s+=' ],
1148911490
[ 'remove_matches' , '^\s*Attribute\s+'],
1149011491
[ 'remove_matches' , '^\s*\47'], # \47 = '
@@ -11494,7 +11495,7 @@ sub set_constants { # {{{1
1149411495
[ 'remove_matches' , '^\s*Attribute\s+'],
1149511496
[ 'remove_matches' , '^\s*\47'], # \47 = '
1149611497
],
11497-
'VB for Applications' => [
11498+
'VBA' => [
1149811499
[ 'remove_above' , '^\s*Attribute\s+VB_Name\s+=' ],
1149911500
[ 'remove_matches' , '^\s*Attribute\s+'],
1150011501
[ 'remove_matches' , '^\s*\47'], # \47 = '
@@ -12225,9 +12226,9 @@ sub set_constants { # {{{1
1222512226
'VHDL' => 4.21,
1222612227
'vim script' => 3.00,
1222712228
'Visual Basic' => 2.76,
12228-
'VB for Applications' => 2.76,
12229+
'VBA' => 2.76,
1222912230
'Visual Basic .NET' => 2.76,
12230-
'Visual Basic Script' => 2.76,
12231+
'VBScript' => 2.76,
1223112232
'Visual Fox Pro' => 4.00, # Visual Fox Pro is not available in the language gearing ratios listed at Mayes Consulting web site
1223212233
'Visualforce Component' => 1.9 ,
1223312234
'Visualforce Page' => 1.9 ,

Unix/t/00_C.t

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1433,9 +1433,14 @@ my @Tests = (
14331433
'args' => '../tests/inputs/gnureadline.vala',
14341434
},
14351435
{
1436-
'name' => 'VB.Net',
1437-
'ref' => '../tests/outputs/VisualBasic.Net.vba.yaml',
1438-
'args' => '../tests/inputs/VisualBasic.Net.vba',
1436+
'name' => 'VBA',
1437+
'ref' => '../tests/outputs/vba_test.vba.yaml',
1438+
'args' => '../tests/inputs/vba_test.vba',
1439+
},
1440+
{
1441+
'name' => 'VB.NET',
1442+
'ref' => '../tests/outputs/vbnet_test.vb.yaml',
1443+
'args' => '../tests/inputs/vbnet_test.vb',
14391444
},
14401445
{
14411446
'name' => 'Velocity Template Language',
@@ -1452,6 +1457,21 @@ my @Tests = (
14521457
'ref' => '../tests/outputs/JetCar.cls.yaml',
14531458
'args' => '../tests/inputs/JetCar.cls',
14541459
},
1460+
{
1461+
'name' => 'Visual Basic (Dsr)',
1462+
'ref' => '../tests/outputs/test.Dsr.yaml',
1463+
'args' => '../tests/inputs/test.Dsr',
1464+
},
1465+
{
1466+
'name' => 'Visual Basic .NET (vbhtml)',
1467+
'ref' => '../tests/outputs/test.vbhtml.yaml',
1468+
'args' => '../tests/inputs/test.vbhtml',
1469+
},
1470+
{
1471+
'name' => 'VBScript',
1472+
'ref' => '../tests/outputs/test.vbs.yaml',
1473+
'args' => '../tests/inputs/test.vbs',
1474+
},
14551475
{
14561476
'name' => 'Visual Studio Solution',
14571477
'ref' => '../tests/outputs/vs_solution.sln.yaml',

cloc

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9608,17 +9608,18 @@ sub set_constants { # {{{1
96089608
'BAS' => 'Visual Basic' ,
96099609
'ctl' => 'Visual Basic' ,
96109610
'dsr' => 'Visual Basic' ,
9611+
'Dsr' => 'Visual Basic' ,
96119612
'frm' => 'Visual Basic' ,
96129613
'frx' => 'Visual Basic' ,
96139614
'FRX' => 'Visual Basic' ,
9614-
'vba' => 'VB for Applications' ,
9615-
'VBA' => 'VB for Applications' ,
9616-
'vbhtml' => 'Visual Basic' ,
9617-
'VBHTML' => 'Visual Basic' ,
9615+
'vba' => 'VBA' ,
9616+
'VBA' => 'VBA' ,
9617+
'vbhtml' => 'Visual Basic .NET' ,
9618+
'VBHTML' => 'Visual Basic .NET' ,
96189619
'vbproj' => 'Visual Basic .NET' ,
96199620
'vbp' => 'Visual Basic' , # .vbp - autogenerated
9620-
'vbs' => 'Visual Basic Script' ,
9621-
'VBS' => 'Visual Basic Script' ,
9621+
'vbs' => 'VBScript' ,
9622+
'VBS' => 'VBScript' ,
96229623
'vb' => 'Visual Basic .NET' ,
96239624
'VB' => 'Visual Basic .NET' ,
96249625
'vbw' => 'Visual Basic' , # .vbw - autogenerated
@@ -11476,7 +11477,7 @@ sub set_constants { # {{{1
1147611477
[ 'remove_matches' , '^\s*"' ],
1147711478
[ 'remove_inline' , '".*$' ],
1147811479
],
11479-
'Visual Basic Script' => [
11480+
'VBScript' => [
1148011481
[ 'remove_above' , '^\s*Attribute\s+VB_Name\s+=' ],
1148111482
[ 'remove_matches' , '^\s*Attribute\s+'],
1148211483
[ 'remove_matches' , '^\s*\47'], # \47 = '
@@ -11486,7 +11487,7 @@ sub set_constants { # {{{1
1148611487
[ 'remove_matches' , '^\s*Attribute\s+'],
1148711488
[ 'remove_matches' , '^\s*\47'], # \47 = '
1148811489
],
11489-
'VB for Applications' => [
11490+
'VBA' => [
1149011491
[ 'remove_above' , '^\s*Attribute\s+VB_Name\s+=' ],
1149111492
[ 'remove_matches' , '^\s*Attribute\s+'],
1149211493
[ 'remove_matches' , '^\s*\47'], # \47 = '
@@ -12217,9 +12218,9 @@ sub set_constants { # {{{1
1221712218
'VHDL' => 4.21,
1221812219
'vim script' => 3.00,
1221912220
'Visual Basic' => 2.76,
12220-
'VB for Applications' => 2.76,
12221+
'VBA' => 2.76,
1222112222
'Visual Basic .NET' => 2.76,
12222-
'Visual Basic Script' => 2.76,
12223+
'VBScript' => 2.76,
1222312224
'Visual Fox Pro' => 4.00, # Visual Fox Pro is not available in the language gearing ratios listed at Mayes Consulting web site
1222412225
'Visualforce Component' => 1.9 ,
1222512226
'Visualforce Page' => 1.9 ,

tests/inputs/VisualBasic.Net.vba

Lines changed: 0 additions & 12 deletions
This file was deleted.

tests/inputs/test.Dsr

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
VERSION 1.0 CLASS
2+
BEGIN
3+
MultiUse = -1 'True
4+
Persistable = 0 'NotPersistable
5+
DataBindingBehavior = 0 'vbNone
6+
DataSourceBehavior = 0 'vbNone
7+
MTSTransactionMode = 0 'NotAnMTSObject
8+
END
9+
Attribute VB_Name = "TestClass"
10+
Attribute VB_GlobalNameSpace = False
11+
12+
' This is a comment in a Dsr file
13+
Option Explicit
14+
15+
Public Sub TestMethod()
16+
' Method implementation
17+
Dim x As Integer
18+
x = 42
19+
Debug.Print "Value: " & x
20+
End Sub

tests/inputs/test.vbhtml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
@{
2+
' VB.NET code in a vbhtml file
3+
ViewBag.Title = "Test Page"
4+
Dim message As String = "Hello from VB.NET"
5+
}
6+
7+
<!DOCTYPE html>
8+
<html>
9+
<head>
10+
<title>@ViewBag.Title</title>
11+
</head>
12+
<body>
13+
<h1>@message</h1>
14+
@If True Then
15+
@<p>This is a VB.NET HTML template</p>
16+
End If
17+
</body>
18+
</html>

tests/inputs/test.vbs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
' VBScript test file
2+
' This is a comment
3+
Dim greeting
4+
greeting = "Hello, World!"
5+
WScript.Echo greeting
6+
7+
' Another comment
8+
If 1 = 1 Then
9+
WScript.Echo "True"
10+
End If

tests/inputs/vba_test.vba

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Attribute VB_Name = "Module1"
2+
' VBA (Visual Basic for Applications) example
3+
' This would typically be found in Excel, Word, or Access
4+
5+
Option Explicit
6+
7+
Sub HelloWorld()
8+
' This is a VBA subroutine
9+
MsgBox "Hello from VBA!"
10+
End Sub
11+
12+
Function AddNumbers(x As Integer, y As Integer) As Integer
13+
' VBA function to add two numbers
14+
AddNumbers = x + y
15+
End Function
16+
17+
Private Sub Worksheet_Change(ByVal Target As Range)
18+
' Event handler - typical in VBA
19+
If Target.Address = "$A$1" Then
20+
Range("B1").Value = "Cell A1 was changed"
21+
End If
22+
End Sub

tests/inputs/vbnet_test.vb

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Imports System
2+
Imports System.Collections.Generic
3+
4+
' VB.NET example
5+
Namespace HelloWorldApp
6+
Public Class Program
7+
Public Shared Sub Main(args As String())
8+
Console.WriteLine("Hello from VB.NET!")
9+
10+
Dim numbers As New List(Of Integer)
11+
numbers.Add(1)
12+
numbers.Add(2)
13+
numbers.Add(3)
14+
15+
For Each num As Integer In numbers
16+
Console.WriteLine($"Number: {num}")
17+
Next
18+
End Sub
19+
20+
' VB.NET method with modern syntax
21+
Public Function CalculateSum(values As List(Of Integer)) As Integer
22+
Return values.Sum()
23+
End Function
24+
End Class
25+
End Namespace

0 commit comments

Comments
 (0)