我正在編寫一個代碼,其中我有一個for循環,其中給出了一個變量(名爲VType
)的一些值。 For循環用於一系列i變量。現在我想通過連接兩個變量的名稱來創建一個新變量。例如,如果我= 1,那麼我想變量VType1。這是我的一段代碼。添加兩個變量的名稱並創建一個新的動態變量
nrec = Split(Split(ie.document.body.innerHTML, "Found <strong>")(1), "</strong> records")(0)
If nrec = 1 Then
lnk.Click
Else
For j = 1 To nrec
link.Click
Do While ie.readyState <> 4: Wait 5: Loop
Application.Wait (Now + TimeValue("0:00:01"))
'VType , j = GetType
'Application.Wait (Now + TimeValue("0:00:01"))
IMO , j = GetValue("IMO:")
'MMSI = GetValue("MMSI:")
YBuilt , j = GetValue("Year Built:")
Flag , j = GetValue("Flag:")
DWT , j = GetValue("Deadweight:")
Next j
num = "1 - " & IMO1
For i = 2 To nrec
num = num & vbCrLf & i & "abc"
Next I
fin = InputBox(num, nrec & " records found for a. please select right one.")
Exit For
End If
我聽說過一種叫*陣列* ... –
[如何創建動態的變量名VBA(可能的重複https://stackoverflow.com/questions/38254337/how-to -create-動態可變名稱-VBA) – trincot