Skip to content

Commit

Permalink
version update
Browse files Browse the repository at this point in the history
Refactored .gitattributes file to preserve Windows line endings (see https://github.com/DecimalTurn/VBA-on-GitHub)
Renamed control json resources with extension .json so that GH recognizes these as text files and preserves their Windows line endings (CrLf)
Fxed .tbform source files Unix line endings (Lf) to Windows line endings (CrLf)
Minor code cleanup
  • Loading branch information
GCuser99 committed Jun 17, 2024
1 parent d04cbf2 commit 9036580
Show file tree
Hide file tree
Showing 41 changed files with 9,585 additions and 5,133 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ A VBIDE add-in that converts VBA UserForms for use in [twinBASIC](https://twinba

***

The [twinBASIC](https://twinbasic.com/preview.html) (in Beta) does not yet support VBA UserForms. It does however have its own excellent (VB6 compatible) native Form designer and associated controls. This simple VBIDE add-in for MS Office applications converts (as much as is possible) a UserForm, its controls, images, and code into a **twinBASIC** form that can be imported directly into **twinBASIC**.
The [twinBASIC](https://twinbasic.com/preview.html) (in Beta) does not yet support VBA UserForms. It does however have its own excellent (VB6 compatible) native Form designer and associated controls. This simple VBIDE add-in for MS Office applications converts a UserForm, its controls, images, and code into a twinBASIC form that can be imported directly into twinBASIC.

This tool (compiled in **twinBASIC**) queries the state of the UserForm and each of its child controls at design time and builds the closest **twinBASIC** equivalent. For non-MS Forms controls or MS Forms controls not supported (see below), a **twinBASIC** Label or Frame control is substituted to flag the missing control. UserForm code is (at least partially) translated and exported in a format that can be imported into **twinBASIC**, along with the form.
This tool, compiled in twinBASIC, queries the state of the UserForm and each of its child controls at design time and builds the closest twinBASIC equivalent. For non-MS Forms controls or MS Forms controls not supported (see below), a twinBASIC Label or Frame control is substituted to flag the missing control. UserForm code is translated and exported in a format that can be imported into twinBASIC, along with the form.

The resulting imported form and code may have to be tweaked in **twinBASIC** to work as desired, but at least the position and most property states will be converted, saving time and tedious effort.
The resulting imported form and code may have to be tweaked in twinBASIC to work as desired, but at least the position and most property states will be converted, saving time and tedious effort.

**MS Forms controls supported**: Label, TextBox, CommandButton, Frame, CheckBox, ComboBox, ListBox, OptionButton, Image, ScrollBar, ToggleButton, and SpinButton.

**MS Forms controls not yet supported**: TabStrip, and MultiPage.

**Extract Image Resources Option**: User can optionally extract and save to file all image resources (mouse icons and picture bitmaps) that are embedded in each UserForm for later use in **twinBASIC** Resources.
**Extract Image Resources Option**: User can optionally extract and save to file all image resources (mouse icons and picture bitmaps) that are embedded in each UserForm for later use in twinBASIC Resources.

<img src="https://github.com/GCuser99/VBA-UserForm-to-twinBASIC/blob/main/images/nested_controls.png" alt="NestedControls" width=95% height=95%>

Expand All @@ -27,7 +27,7 @@ The resulting imported form and code may have to be tweaked in **twinBASIC** to
## Quick How-To-Use

1) Make sure to close all MS Office applications.
2) Download and run the tBUserformConverterSetup.exe Inno installer.
2) Download and run the [tBUserformConverterSetup.exe Inno installer](https://github.com/GCuser99/VBA-UserForm-to-twinBASIC/tree/main/dist).
3) Open an MS Office document that contains UserForm(s) to be converted.
4) Open the Visual Basic for Application IDE.
5) You should see the "twinBASIC Tools" menu item on the far right of the main menu bar.
Expand Down
256 changes: 256 additions & 0 deletions Sources/About.tbform
Original file line number Diff line number Diff line change
@@ -0,0 +1,256 @@
[
{
"AlwaysShowKeyboardCues": false,
"Appearance": "vbAppear3d",
"AutoRedraw": false,
"BackColor": -2147483633,
"BorderStyle": "vbFixedSingle",
"Caption": "About tBUserFormConverter",
"ClipControls": true,
"ControlBox": true,
"DrawMode": "vbCopyPen",
"DrawStyle": "vbSolid",
"DrawWidth": 1,
"Enabled": true,
"FillColor": 0,
"FillStyle": "vbFSTransparent",
"FontBold": false,
"FontItalic": false,
"FontName": "Segoe UI",
"FontSize": 8,
"FontStrikethru": false,
"FontTransparent": true,
"FontUnderline": false,
"ForeColor": -2147483630,
"FormDesignerId": "{AD8254FE-96CD-45BA-9FFC-44D12AFE5BBB}",
"HasDC": true,
"Height": 152,
"HelpContextID": 0,
"Icon": "",
"Index": -1,
"KeyPreview": false,
"Left": 0,
"LinkMode": "vbLinkNone",
"LinkTopic": null,
"MDIChild": false,
"MaxButton": false,
"MaxHeight": 0,
"MaxWidth": 0,
"MinButton": false,
"MinHeight": 0,
"MinWidth": 0,
"MouseIcon": "",
"MousePointer": "vbDefault",
"Moveable": true,
"Name": "About",
"NegotiateMenus": false,
"OLEDropMode": "vbOLEDropNone",
"Opacity": 100,
"Palette": "",
"PaletteMode": "vbPaletteModeHalftone",
"Picture": "",
"PictureDpiScaling": true,
"RightToLeft": false,
"ScaleHeight": 2280,
"ScaleLeft": 0,
"ScaleMode": "vbTwips",
"ScaleTop": 0,
"ScaleWidth": 4680,
"ShowInTaskbar": true,
"StartUpPosition": "vbStartUpScreen",
"TabFocusAutoSelect": false,
"Tag": null,
"Top": 0,
"TopMost": false,
"TransparencyKey": -1,
"Visible": true,
"WhatsThisButton": false,
"WhatsThisHelp": false,
"Width": 312,
"WindowState": "vbNormal",
"__IDEOptions": {
"alignToGrid": false,
"gridHeight": 10,
"gridWidth": 10,
"lockedControls": [],
"multiColoredGrabbers": false,
"showGrid": true,
"showOutlines": false
},
"__lastUpdateMarker": 621404605,
"_children": [
{
"Alignment": "vbLeftJustify",
"Anchors": {
"Bottom": false,
"Left": true,
"Right": false,
"Top": true,
"_className": "Anchors",
"_clsid": "{8524D4B5-72A9-40A9-A189-29E7905C40CA}"
},
"Appearance": "vbAppear3d",
"AutoSize": false,
"BackColor": -2147483633,
"BackStyle": "vbBFOpaque",
"BorderStyle": "vbNoBorder",
"Caption": "Info Label",
"DataField": null,
"DataFormat": null,
"DataMember": null,
"DataSource": null,
"Dock": "vbDockNone",
"DragIcon": "",
"DragMode": "vbManual",
"Enabled": true,
"FontBold": false,
"FontItalic": false,
"FontName": "Segoe UI",
"FontSize": 8,
"FontStrikethru": false,
"FontUnderline": false,
"ForeColor": -2147483630,
"Height": 68,
"Index": -1,
"Left": 13,
"LinkItem": null,
"LinkMode": "vbLinkNone",
"LinkTimeout": 50,
"LinkTopic": null,
"MouseIcon": "",
"MousePointer": "vbDefault",
"Name": "lblInfo",
"OLEDropMode": "vbOLEDropNone",
"RightToLeft": false,
"TabIndex": 1,
"Tag": null,
"ToolTipText": null,
"Top": 18,
"UseMnemonic": true,
"Visible": true,
"WhatsThisHelpID": 0,
"Width": 273,
"WordWrap": true,
"_className": "Label",
"_clsid": "{33AD4ED8-6699-11CF-B70C-00AA0060D393}",
"_paintedByParent": true
},
{
"Anchors": {
"Bottom": false,
"Left": true,
"Right": false,
"Top": true,
"_className": "Anchors",
"_clsid": "{8524D4B5-72A9-40A9-A189-29E7905C40CA}"
},
"Appearance": "vbAppear3d",
"BackColor": -2147483633,
"Cancel": false,
"Caption": "Dismiss",
"CausesValidation": true,
"Default": false,
"DisabledPicture": "",
"Dock": "vbDockNone",
"DownPicture": "",
"DragIcon": "",
"DragMode": "vbManual",
"Enabled": true,
"FontBold": false,
"FontItalic": false,
"FontName": "Segoe UI",
"FontSize": 8,
"FontStrikethru": false,
"FontUnderline": false,
"ForeColor": -2147483630,
"Height": 26,
"HelpContextID": 0,
"Index": -1,
"Left": 210,
"MaskColor": 12632256,
"MouseIcon": "",
"MousePointer": "vbDefault",
"Name": "cmdOK",
"OLEDropMode": "vbOLEDropNone",
"Opacity": 100,
"Padding": 2,
"Picture": "",
"PictureAlignment": "vbAlignTop",
"PictureDpiScaling": false,
"RightToLeft": false,
"Style": "vbButtonStandard",
"TabIndex": 2,
"TabStop": true,
"Tag": null,
"ToolTipText": null,
"Top": 118,
"TransparencyKey": -1,
"UseMaskColor": false,
"Visible": true,
"VisualStyles": true,
"WhatsThisHelpID": 0,
"Width": 89,
"_className": "CommandButton",
"_clsid": "{33AD4EF0-6699-11CF-B70C-00AA0060D393}"
},
{
"Alignment": "vbLeftJustify",
"Anchors": {
"Bottom": false,
"Left": true,
"Right": false,
"Top": true,
"_className": "Anchors",
"_clsid": "{8524D4B5-72A9-40A9-A189-29E7905C40CA}"
},
"Appearance": "vbAppear3d",
"AutoSize": false,
"BackColor": -2147483633,
"BackStyle": "vbBFOpaque",
"BorderStyle": "vbNoBorder",
"Caption": "Website Label",
"DataField": null,
"DataFormat": null,
"DataMember": null,
"DataSource": null,
"Dock": "vbDockNone",
"DragIcon": "",
"DragMode": "vbManual",
"Enabled": true,
"FontBold": false,
"FontItalic": false,
"FontName": "Segoe UI",
"FontSize": 8,
"FontStrikethru": false,
"FontUnderline": false,
"ForeColor": -2147483630,
"Height": 18,
"Index": -1,
"Left": 14,
"LinkItem": null,
"LinkMode": "vbLinkNone",
"LinkTimeout": 50,
"LinkTopic": null,
"MouseIcon": "",
"MousePointer": "vbDefault",
"Name": "lblWebsite",
"OLEDropMode": "vbOLEDropNone",
"RightToLeft": false,
"TabIndex": 3,
"Tag": null,
"ToolTipText": null,
"Top": 92,
"UseMnemonic": true,
"Visible": true,
"WhatsThisHelpID": 0,
"Width": 287,
"WordWrap": false,
"_className": "Label",
"_clsid": "{33AD4ED8-6699-11CF-B70C-00AA0060D393}",
"_paintedByParent": true
}
],
"_className": "Form",
"_clsid": "{33AD4F38-6699-11CF-B70C-00AA0060D393}"
}
]
25 changes: 25 additions & 0 deletions Sources/About.twin
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[Description("")]
[FormDesignerId("AD8254FE-96CD-45BA-9FFC-44D12AFE5BBB")]
[PredeclaredId]
Class About

Sub New()
lblInfo.Caption = "Author: GCUser99" & vbCrLf & _
"Version: " & App.Major & "." & App.Minor & vbCrLf & _
"Description: A VBIDE add-in (complied with twinBASIC) that converts VBA UserForms for use in twinBASIC."
lblWebsite.Caption = "https://github.com/GCuser99/VBA-UserForm-to-twinBASIC"
Set Me.Icon = Global.LoadResPicture("About_32.ico", vbResIcon)
End Sub

Private Sub cmdOK_Click()
Me.Close
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
If UnloadMode = vbFormControlMenu Then
Cancel = True
Me.Close
End If
End Sub

End Class
Loading

0 comments on commit 9036580

Please sign in to comment.