What needs to be changed or added for the following code to work? I program mostly in Java now, and I've forgotten alot of my Visual Basic.
Option Explicit
Private Sub cmdEncode_Click()
Dim key1 As String
Dim key2 As String
key1 = UCase(txtKey1.Text)
key2 = UCase(txtKey2.Text)
If ValidateKey(key1, "Validating key 1...", "Key 1 not valid!") = False Then
Exit Sub
End If
If ValidateKey(key2, "Validating key 2...", "Key 2 not valid!") = False Then
Exit Sub
End If
Dim i As Integer
For i = 1 To Len(key1)
ProgressBar.Value = i
Dim x As Integer
For x = 0 To i - 1
If lblKey1(x).Caption <> Mid(key1, i, 1) Then
lblKey1(i - 1).Caption = Mid(key1, i, 1)
End If
Next x
Next i
End Sub
Private Function ValidateKey(ByVal key As String, ByVal status As String, ByVal error As String) As Boolean
Dim check(Len(key)) As String
Dim i As Integer
lblStatus.Caption = status
ProgressBar.Min = 1
ProgressBar.Max = Len(key)
For i = 1 To Len(key)
ProgressBar.Value = i
Dim x As Integer
For x = 0 To i - 1
If check1(x) <> Mid(key, i, 1) Then
check1(i - 1) = Mid(key, i, 1)
Else
ProgressBar.Value = 0
lblStatus.Caption = error
ValidateKey = False
Exit Function
End If
Next x
Next i
ValidateKey = True
End Function
This throws the following error:
Quote
Compile error:
Constant expression required
When you follow the debug it takes you to these lines:
Private Function ValidateKey(ByVal key As String, ByVal status As String, ByVal error As String) As Boolean
Dim check(Len(key)) As String
It highlights the function with yellow and then selects the text "key" in "Len(key)" as the source of the error.
You could upgrade it to the latest Android 15 with LineageOS, its still a supported device: https://wiki.lineageos.org/devices/beryllium/
Granted probably not much point if its just an MP3 player, however with 6/8gb of ram it could still make a good backup device.
Having been using Windows for 30 years and 3 Surface Pros in the meantime (4,6,9) and recently bought a 15" macbook air m4.
The OS is indeed a big deal.
Hardware wise the surface pro feels as nice as macbook air, but Windows...man it's it's own enemy now
Question
Delox
What needs to be changed or added for the following code to work? I program mostly in Java now, and I've forgotten alot of my Visual Basic.
This throws the following error:
When you follow the debug it takes you to these lines:
It highlights the function with yellow and then selects the text "key" in "Len(key)" as the source of the error.
Link to comment
https://www.neowin.net/forum/topic/398028-vb6-boolean-function/Share on other sites
15 answers to this question
Recommended Posts