vba11-6.txt

来自「本书给出了AO的常用的VAB代码 可能是初学者很好的一本参考书」· 文本 代码 · 共 36 行

TXT
36
字号
Public Sub UseGetStringDialog()
  Dim pGetStringDialog As IGetStringDialog
  Dim pMessageDialog As IMessageDialog
  Dim blnOK As Boolean
  Dim blnYes As Boolean
  Dim strName As String
  
  ' Initiate the variables and objects
  strName = "Bob"
  blnYes = False
  Set pGetStringDialog = New GetStringDialog
  Set pMessageDialog = New MessageDialog
  
  ' Place the process in a loop so that
  ' it can be repeated.
  Do While Not blnYes
    ' Display the Get String Dialog.
    blnOK = pGetStringDialog.DoModal( _
    "Get String Dialog Example", "Name:", strName, 0)
    If blnOK Then
      ' Get the name that user provided.
      strName = pGetStringDialog.Value
      ' Display the Message Dialog.
      blnYes = pMessageDialog.DoModal( _
      "Message Dialog Example", _
      "Is your name " & strName & "?", _
      "Yes", "No", 0)
    Else
      ' User selected the Cancel button,
      ' end the macro.
      Exit Do
    End If
  Loop
End Sub

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?