如何显示变量的注释行?

How to show the comment line from a variable?

我需要显示一个带有变量值的 MsgBox,以及该变量的注释行。

Sub Main

Dim Sys As Object, Sess As Object, MyScreen As Object
Set Sys = CreateObject("EXTRA.System")
Set Sess = Sys.ActiveSession
Set MyScreen = Sess.Screen

Dim a(3) as string, i as integer

a(0) = "123 321 231" ' Lorem ipsum dolor sit amet
a(1) = "211 321 331" ' Consectetur adipiscing elit
a(2) = "121 331 111" ' Sed do eiusmod tempor incididunt
a(3) = "511 321 277" ' Quis nostrud exercitation ullamco

for i = 0 to ubound(a)
  if a(i) = Sess.screen.GetString(04, 19, 11) then msgbox a(i) & "Plus the comment line"
next

End Sub

如果您改用锯齿状数组 'a' 一切都会好起来的。

Sub Main()

    Dim Sys As Object, Sess As Object, MyScreen As Object
    Set Sys = CreateObject("EXTRA.System")
    Set Sess = Sys.ActiveSession
    Set MyScreen = Sess.screen

    Dim a(3) As Variant, i As Integer

    a(0) = Array("123 321 231", "Lorem ipsum dolor sit amet")
    a(1) = Array("211 321 331", "Consectetur adipiscing elit")
    a(2) = Array("121 331 111", "Sed do eiusmod tempor incididunt")
    a(3) = Array("511 321 277", "Quis nostrud exercitation ullamco")

    For i = 0 To UBound(a)
        If a(i)(0) = Sess.screen.GetString(4, 19, 11) Then MsgBox a(i)(0) & a(i)(1)
    Next

'  Or in a more expressive way
    
'    Dim myItem As Variant
'    For Each myItem In a
'
'        If myItem(0) = Sess.screen.GetString(4, 19, 11) Then MsgBox myItem(0) & myItem(1)
'
'    Next

End Sub