0

查看这些消息框图像

1:http ://catalinx.homeftp.org/img/Autoiterror1.jpg 2:http ://www.exceltrick.com/wp-content/uploads/2013/02/Messagebox-Example-5.png

我可以在记事本中使用 vbs 创建这样的消息框,如第一张图片所示。但是点击按钮就像在第二张图片中一样。如何解决?我正在制作一个 HTA 应用程序。

我在问如何以新样式添加特定的一组按钮。例如看2种方法:

MsgBox "Hello", 48

Alert "Hello"

两者都用感叹号显示相同的东西。但是OK按钮的样式不同。如果我们使用第 2 个,它比第 1 个更漂亮。所以我想在第二种方法中添加一个取消按钮,如下所示

Msgbox "Hello",17

如何?

4

5 回答 5

1
X=MsgBox ("hello",48, " ")

描述:

X=MsgBox ("your message",(button options) ,"title")
于 2015-02-14T11:22:02.427 回答
1

你不能。Alert只接受一个参数:要显示的消息。如果您想控制图标和/或按钮,您必须使用MsgBox或构建您自己的自定义对话框

于 2013-09-14T19:35:02.897 回答
1

我知道这篇文章有点旧,但我偶然发现它正在寻找其他东西。既然我在这里......

每当我使用 msgBox 时,我都会将这个小 VBScript 放在手边,并且想不出我头顶的反应。您想要是/否、确定/取消、中止/重试/取消……?只需将其粘贴到带有记事本的 .VBS 文件中以供将来参考。

编辑文件以查看您或正在查找的按钮语法,或双击 VBS 以查看它们各自的工作方式。

享受!

Sample = msgBox("Option codes 0+64." & vbCrLf & vbCrLf & "This is an information situation with OK only",0+64, "Information.")
    Select Case Sample
        Case 1
            wScript.Echo "You acknowledged."
    End Select

Sample = msgBox("Option codes 1+48." & vbCrLf & vbCrLf & "This is a warning situation with OK and Cancel",1+48, "WARNING!")
    Select Case Sample
        Case 1
            wScript.Echo "You chose OK."
        Case 2
            wScript.Echo "You chose Cancel."
    End Select

Sample = msgBox("Option codes 2+16." & vbCrLf & vbCrLf & "This is a critical situation with Abort, Retry, and Ignore",2+16, "CRITICAL!")
    Select Case Sample
        Case 3
            wScript.Echo "You chose Abort."
        Case 4
            wScript.Echo "You chose Retry."
    Case 5
        wScript.Echo "You chose Ignore."
    End Select

Sample = msgBox("Option codes 0+16." & vbCrLf & vbCrLf & "This is a critical error situation with OK only",0+16, "CRITICAL ERROR!")
    Select Case Sample
        Case 1
            wScript.Echo "You acknowledged."
    End Select

Sample = msgBox("Option codes 3+32." & vbCrLf & vbCrLf & "This is a question situation with Yes, No, or Cancel",3+32, "Question?")
    Select Case Sample
        Case 6
            wScript.Echo "You said Yes."
        Case 7
            wScript.Echo "You said No."
        Case 2
            wScript.Echo "You clicked Cancel."
    End Select

Sample = msgBox("Option codes 4+32." & vbCrLf & vbCrLf & "This is a question situation with Yes or No only",4+32, "Question?")
    Select Case Sample
        Case 6
            wScript.Echo "You said Yes."
        Case 7
            wScript.Echo "You said No."
    End Select

Sample = msgBox("Option codes 5+16." & vbCrLf & vbCrLf & "This is a critical error situation with Retry or Cancel",5+16, "CRITICAL ERROR!")
    Select Case Sample
        Case 4
            wScript.Echo "You clicked Retry."
        Case 2
            wScript.Echo "You clicked Cancel."
    End Select
于 2015-09-29T23:53:04.480 回答
0

HTA 文件 cab 由 VBS 文件创建然后删除:

Set fso = CreateObject("Scripting.FileSystemObject") 

sHtml = "<div>Value 1 " & _
    "<input id='txt1' style='width: 100px'>" & _
  "</div>" & _
  "<div>Value 2 " & _
    "<select id='txt2' style='width: 100px'>" & _
      "<option value='A'>A</option>" & _
      "<option value='B'>B</option>" & _
      "<option value='C'>D</option>" & _
    "</select>" & _
  "</div>" & _
  "<p align=center>" & _
    "<input type='button' value='Send' onclick='Send()'> " & _
    "<input type='button' value='Close' onclick='self.Close()'>" & _
  "</p>"

  Set oRet = OpenDialog(sHtml, "txt1,txt2", 300, 200, "Dialog 1")
  MsgBox "Value 1: " & oRet("txt1") & ", Value 2: " & oRet("txt2")

'==================================
Function OpenDialog(sHtml, sFields,iWidth,iHeight, sTitle)
  sHtaFilePath = Wscript.ScriptFullName & ".hta"

  CreateHtaFile sHtaFilePath, sHtml, sFields,iWidth,iHeight,sTitle

  Set f = fso.GetFile(sHtaFilePath)
  f.attributes = f.attributes + 2 'Hidden

  Dim oShell: Set oShell = CreateObject("WScript.Shell")

  oShell.Run """" & sHtaFilePath & """", 1, True

  If fso.FileExists(sHtaFilePath) Then
    fso.DeleteFile sHtaFilePath
  End If

  Set oRet = CreateObject("Scripting.Dictionary")

  'Load return data from XML File
  If fso.FileExists(sHtaFilePath & ".xml") Then
      Set oXml = CreateObject("Microsoft.XMLDOM")
      oXML.async = False
      oXML.load sHtaFilePath & ".xml"

      For each sField In Split(sFields,",")
        oRet.Add trim(sField), oXML.SelectSingleNode("/root/" & trim(sField)).text
      Next

      fso.DeleteFile sHtaFilePath & ".xml"
  End If

  Set OpenDialog = oRet
End Function

Sub CreateHtaFile(sHtaFilePath, sHtml, sFields, iWidth, iHeight, sTitle)
  Set f = fso.CreateTextFile(sHtaFilePath, True)
  f.WriteLine "<html><title>FL Reporting</title><head><HTA:APPLICATION ID=oHTA SINGLEINSTANCE=""yes"" SCROLL=""no""/></head>"
  f.WriteLine "<script language=""vbscript"">"
  f.WriteLine "Window.ResizeTo " & iWidth & ", " & iHeight
  f.WriteLine "Set fso = CreateObject(""Scripting.FileSystemObject"")"
  f.WriteLine ""
  f.WriteLine "Sub Send()"
  f.WriteLine " Dim sFilePath: sFilePath = Replace(location.href,""file:///"","""")"
  f.WriteLine " sFilePath = Replace(sFilePath,""/"",""\"")"
  f.WriteLine " sFilePath = Replace(sFilePath,""%20"","" "")"
  f.WriteLine " Set oXml = CreateObject(""Microsoft.XMLDOM"")"
  f.WriteLine " Set oRoot = oXml.createElement(""root"")"
  f.WriteLine " oXml.appendChild oRoot"

  For each sField In Split(sFields,",")
    f.WriteLine " AddXmlVal oXml, oRoot, """ & sField & """, GetVal(" & sField & ")"
  Next

  f.WriteLine " oXml.Save sFilePath & "".xml"""
  f.WriteLine " self.Close()"
  f.WriteLine "End Sub"
  f.WriteLine ""
  f.WriteLine "Sub AddXmlVal(oXml, oRoot, sName, sVal)"
  f.WriteLine " Set oNode = oXml.createElement(sName)"
  f.WriteLine " oNode.Text = sVal"
  f.WriteLine " oRoot.appendChild oNode"
  f.WriteLine "End Sub"
  f.WriteLine ""
  f.WriteLine "Function GetVal(o)"
  f.WriteLine " GetVal = o.value"
  f.WriteLine " If o.Type = ""checkbox"" Then"
  f.WriteLine "   If o.checked = False Then"
  f.WriteLine "     GetVal = """""
  f.WriteLine "   End If"
  f.WriteLine " End If"
  f.WriteLine "End Function"  
  f.WriteLine "</script>"
  f.WriteLine "<body>"
  f.WriteLine sHtml
  f.WriteLine "</body></html>"
  f.Close
End Sub
于 2020-01-21T14:54:06.003 回答
0

这是直接从 vbsedit.com 撕下来的:

intButton = object.Popup(strText,[nSecondsToWait],[strTitle],[nType]) 
于 2021-06-12T15:59:30.283 回答