Conversion showcase: CONVOD.bas helpers
These examples show how the VBAtoPython converter handles real-world utility functions from CONVOD.bas. The Python shown is syntactically valid and representative of the cleaned drafts the engine produces; complex projects may still need light manual review.
At a glance
(Images coming soon)
QBColorName – from legacy colors to clean Python
Original VBA
' QBColorName: map QBColor index to a friendly name
Public Function QBColorName(I As Integer) As String
Select Case I
Case 0: QBColorName = "Black"
Case 1: QBColorName = "Blue"
Case 2: QBColorName = "Green"
Case 3: QBColorName = "Cyan"
Case 4: QBColorName = "Red"
Case 5: QBColorName = "Magenta"
Case 6: QBColorName = "Yellow"
Case 7: QBColorName = "White"
Case 8: QBColorName = "Gray"
Case 9: QBColorName = "Light Blue"
Case 10: QBColorName = "Light Green"
Case 11: QBColorName = "Light Cyan"
Case 12: QBColorName = "Light Red"
Case 13: QBColorName = "Light Magenta"
Case 14: QBColorName = "Light Yellow"
Case 15: QBColorName = "Bright White"
End Select
End Function
Converted Python (auto-generated, lightly cleaned)
def qb_color_name(i: int) -> str:
"""Map a QBColor index (0-15) to a friendly color name."""
if i == 0:
return "Black"
elif i == 1:
return "Blue"
elif i == 2:
return "Green"
elif i == 3:
return "Cyan"
elif i == 4:
return "Red"
elif i == 5:
return "Magenta"
elif i == 6:
return "Yellow"
elif i == 7:
return "White"
elif i == 8:
return "Gray"
elif i == 9:
return "Light Blue"
elif i == 10:
return "Light Green"
elif i == 11:
return "Light Cyan"
elif i == 12:
return "Light Red"
elif i == 13:
return "Light Magenta"
elif i == 14:
return "Light Yellow"
elif i == 15:
return "Bright White"
return ""
Complexity: Low
Features handled:
- Select Case → if/elif chain
- Constant mapping of legacy color IDs
- Simple return values
Notes / warnings:
- Out-of-range values return an empty string; adjust if you prefer raising or defaults.
- No localization of color names.
Int2RomanNumeral – numeric formatting without VBA
Original VBA
Private Function Int2RomanNumeral(ByVal I As Integer) As String
Dim N As Integer
Dim S As String
N = I
If N <= 0 Or N >= 4000 Then
Int2RomanNumeral = ""
Exit Function
End If
S = ""
S = S & Int2RomanDigit(Int(N / 1000), "M", "", "")
N = N Mod 1000
S = S & Int2RomanDigit(Int(N / 100), "C", "D", "M")
N = N Mod 100
S = S & Int2RomanDigit(Int(N / 10), "X", "L", "C")
N = N Mod 10
S = S & Int2RomanDigit(N, "I", "V", "X")
Int2RomanNumeral = S
End Function
Private Function Int2RomanDigit(ByVal N As Integer, ByVal One As String, ByVal Five As String, ByVal Ten As String) As String
Select Case N
Case 0 To 3: Int2RomanDigit = String(N, One)
Case 4: Int2RomanDigit = One & Five
Case 5 To 8: Int2RomanDigit = Five & String(N - 5, One)
Case 9: Int2RomanDigit = One & Ten
End Select
End Function
Converted Python (auto-generated, lightly cleaned)
def int2_roman_digit(n: int, one: str, five: str, ten: str) -> str:
"""Convert a single digit (0-9) to its Roman fragment."""
if 0 <= n <= 3:
return one * n
if n == 4:
return one + five
if 5 <= n <= 8:
return five + (one * (n - 5))
if n == 9:
return one + ten
return ""
def int2_roman_numeral(value: int) -> str:
"""Convert an integer (1..3999) to a Roman numeral."""
n = value
if n <= 0 or n >= 4000:
return ""
parts: list[str] = []
parts.append(int2_roman_digit(int(n / 1000), "M", "", ""))
n = n % 1000
parts.append(int2_roman_digit(int(n / 100), "C", "D", "M"))
n = n % 100
parts.append(int2_roman_digit(int(n / 10), "X", "L", "C"))
n = n % 10
parts.append(int2_roman_digit(n, "I", "V", "X"))
return "".join(parts)
Complexity: Medium
Features handled:
- Early return guard for out-of-range inputs
- Integer division/modulo for place values
- Helper function reuse for digit-level formatting
Notes / warnings:
- Only supports 1–3999, matching the original VBA constraints.
- No lowercase/variant numeral styles; extend if needed.
Int2String – readable words for large integers
Original VBA
Private Function Int2String(ByVal I As Double) As String
Dim Negative As Integer
Dim Words As String
Negative = I < 0
If Negative Then I = Abs(I)
If I = 0 Then
Int2String = "Zero"
Exit Function
End If
Words = ""
If I >= 1000000000# Then
Words = Words & ABC2String(Int(I / 1000000000#)) & " Billion"
I = I - Int(I / 1000000000#) * 1000000000#
End If
If I >= 1000000# Then
If Words <> "" Then Words = Words & " "
Words = Words & ABC2String(Int(I / 1000000#)) & " Million"
I = I - Int(I / 1000000#) * 1000000#
End If
If I >= 1000# Then
If Words <> "" Then Words = Words & " "
Words = Words & ABC2String(Int(I / 1000#)) & " Thousand"
I = I - Int(I / 1000#) * 1000#
End If
If I > 0 Then
If Words <> "" Then Words = Words & " "
Words = Words & ABC2String(Int(I))
End If
If Negative Then Words = "Minus " & Words
Int2String = Words
End Function
Private Function ABC2String(ByVal I As Integer) As String
Dim S As String
S = ""
If I >= 100 Then
S = Units(Int(I / 100)) & " Hundred"
I = I Mod 100
If I > 0 Then S = S & " "
End If
Select Case I
Case 0 To 9
S = S & Units(I)
Case 10 To 19
S = S & Teens(I - 10)
Case Else
S = S & Exty(Int(I / 10))
If (I Mod 10) > 0 Then S = S & "-" & Units(I Mod 10)
End Select
ABC2String = S
End Function
Private Function Units(ByVal I As Integer) As String
Select Case I
Case 0: Units = "Zero"
Case 1: Units = "One"
Case 2: Units = "Two"
Case 3: Units = "Three"
Case 4: Units = "Four"
Case 5: Units = "Five"
Case 6: Units = "Six"
Case 7: Units = "Seven"
Case 8: Units = "Eight"
Case 9: Units = "Nine"
End Select
End Function
Private Function Teens(ByVal I As Integer) As String
Select Case I
Case 0: Teens = "Ten"
Case 1: Teens = "Eleven"
Case 2: Teens = "Twelve"
Case 3: Teens = "Thirteen"
Case 4: Teens = "Fourteen"
Case 5: Teens = "Fifteen"
Case 6: Teens = "Sixteen"
Case 7: Teens = "Seventeen"
Case 8: Teens = "Eighteen"
Case 9: Teens = "Nineteen"
End Select
End Function
Private Function Exty(ByVal I As Integer) As String
Select Case I
Case 2: Exty = "Twenty"
Case 3: Exty = "Thirty"
Case 4: Exty = "Forty"
Case 5: Exty = "Fifty"
Case 6: Exty = "Sixty"
Case 7: Exty = "Seventy"
Case 8: Exty = "Eighty"
Case 9: Exty = "Ninety"
End Select
End Function
Converted Python (auto-generated, lightly cleaned)
def units(i: int) -> str:
"""Return the word for a single digit (0-9)."""
mapping = {
0: "Zero",
1: "One",
2: "Two",
3: "Three",
4: "Four",
5: "Five",
6: "Six",
7: "Seven",
8: "Eight",
9: "Nine",
}
return mapping.get(i, "")
def teens(i: int) -> str:
"""Return the word for 10-19."""
mapping = {
0: "Ten",
1: "Eleven",
2: "Twelve",
3: "Thirteen",
4: "Fourteen",
5: "Fifteen",
6: "Sixteen",
7: "Seventeen",
8: "Eighteen",
9: "Nineteen",
}
return mapping.get(i, "")
def exty(i: int) -> str:
"""Return the word for tens (20, 30, ... 90)."""
mapping = {
2: "Twenty",
3: "Thirty",
4: "Forty",
5: "Fifty",
6: "Sixty",
7: "Seventy",
8: "Eighty",
9: "Ninety",
}
return mapping.get(i, "")
def abc2string(i: int) -> str:
"""Convert 0-999 into words."""
parts: list[str] = []
if i >= 100:
parts.append(f"{units(int(i / 100))} Hundred")
i = i % 100
if i > 0:
parts.append("")
if 10 <= i <= 19:
parts.append(teens(i - 10))
elif i >= 20:
tens = exty(int(i / 10))
ones = units(i % 10)
parts.append(f"{tens}-{ones}" if ones else tens)
elif i > 0:
parts.append(units(i))
return " ".join(part for part in parts if part) if parts else "Zero"
def int2string(value: float) -> str:
"""Convert an integer value into English words (billions down to ones)."""
negative = value < 0
n = abs(int(value))
if n == 0:
return "Zero"
chunks: list[str] = []
if n >= 1_000_000_000:
chunks.append(f"{abc2string(int(n / 1_000_000_000))} Billion")
n = n % 1_000_000_000
if n >= 1_000_000:
chunks.append(f"{abc2string(int(n / 1_000_000))} Million")
n = n % 1_000_000
if n >= 1000:
chunks.append(f"{abc2string(int(n / 1000))} Thousand")
n = n % 1000
if n > 0:
chunks.append(abc2string(int(n)))
words = " ".join(chunk for chunk in chunks if chunk)
return f"Minus {words}" if negative else words
Complexity: Medium
Features handled:
- Negative handling and absolute value conversion
- Billion/Million/Thousand chunking with remainders
- Hyphenated tens and basic unit/teen lookups
- Helper reuse across the main formatter
Notes / warnings:
- Rounds floats toward zero (casts to
int), matching the original VBA behavior. - Does not handle decimals or “and” phrasing (e.g., “One Hundred and One”); add if needed.
- Maximum range limited by Python int, but wording only defined up to billions in this sample.
Conversion stats
lines_in: non-empty lines in the original VBA input.lines_out: non-empty lines in the cleaned Python draft.warning_count: how many warnings the engine raised (complex constructs, manual review flags).complexity_level: heuristic bucket (low/medium/high) based on size and warnings.approx_effort_saved_minutes: rough estimate of reviewer time saved versus rewriting from scratch. These are directional only, not guarantees.
How to read these examples
- These snippets are representative of typical VBA utility conversions; they are not a guarantee for every macro.
- The converter focuses on control flow, declarations, and common VBA constructs, producing readable Python drafts.
- Complex patterns (heavy
On Error,Goto, deeply nestedWith, or late-bound COM specifics) may need AI-assisted refinement or manual cleanup.
Try it yourself
- Upload a
.bas,.cls, or.frmmodule to the Pro+ converter to get a cleaned Python draft and optional.pydownload. - Start with smaller utility modules to validate the output style, then move to larger projects.
- Enterprise batch can process multiple modules (per-file
.pyoutputs) if you need to convert larger codebases in one run.