Я хотел бы получить доступ к значению строки при объявлении новых переменных, чтобы я мог объявить новые переменные в цикле.
Я пробовал val (), создавая функцию. Упрощенная версия моей проблемы может быть найдена в коде ниже.
Function StudentValue(x As String) As String
StudentValue = x
End Function
Public Sub TEST()
Dim i As Integer
Dim strName As String
Dim n As Integer
n = 20
For i = 1 To n
strName = "Variable" & CStr(i)
'The problem occurs with the next two lines,
'once active they create a string with the name 'strName' and not the
'value of the string eg 'Variable1', 'Variable2', ect
'Attempt1
'Dim strName As String
'Attempt2
'Dim NameFunction(strName) As String
Next i
End Sub
Ошибки следующие:
Dim strName As String results in "compile error: Duplicate declaration in current scope"
Dim NameFunction(strName) As String results in "compile error: Constant expression required"
Есть ли функция, которая позволяет вам получить доступ к значению строки при объявлении переменных?
Заранее спасибо!