我可以使用一个variables来命名其他variables吗?

我正在处理一些需要存储大量数据的代码,我想为它们写入一个新的数据types。

Private Sub CommandButton1_Click() Dim myFile As String, text As String myFile = Application.GetOpenFilename() Open myFile For Input As #1 Do Until EOF(1) Line Input #1, text 'Check to see if line contains name If InStr(text, "name=") <> 0 Then 'Trim down to just name text = Replace(text, "name=", "") text = Trim(text) 'Set the current value of text as name of new scalarIn Dim text As scalarIn End If Loop End Sub 

我不认为这有效,但更多的是帮助理解这个想法。 我想要发生的是从文件中读取名称,并将其设置为我的自定义数据types的新实例的名称。

 Public Type scalarIn UnitOfMeasure As String Value As Variant Source As String End Type