I’m starting to migrate from Excel VBA to Calc Basic. I’ve looked through various help articles but don’t seem to quite be able to convert this Sub from VBA to Basic.
The Sub simply takes a character string from a textbox and displays a message splitting them up, e.g. “abcd” would display as “1:a, 2:b, 3:c, 4:d”.
This is my code (with the commented out line showing what the old VBA code). I’ve tried various different things for the UserChars row but whateve I try it doesn’t populate the array at all.
Sub CharExtract() Dim CharCount As Long Dim i As Integer Dim Result As String Dim UserChars() As String Dim UserString As String UserString = Trim(InputBox("Type or paste data here", "Character Extractor")) If UserString = "" Then Exit Sub 'UserChars = Split(StrConv(UserString, vbUnicode), Chr(0)) UserChars = Split(UserString,Chr(0),Len(UserString)) CharCount = UBound(UserChars) - LBound(UserChars) For i = LBound(UserChars) To UBound(UserChars) - 1 Result = Result & vbCrLf & i + 1 & ": " & vbTab & UserChars(i) Next i Msgbox Result, 64, "Character Extractor" End Sub
Hope someone may be able to help me, so thanks in advance.