Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use vbscript to display a hyperlink in a message box

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly shows you "how to use vbscript to display a hyperlink in the message box", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to use vbscript to display a hyperlink in the message box" this article.

The code is as follows:

Set objShell = CreateObject ("Wscript.Shell")

IntMessage = Msgbox ("Would you like to apply for access to this resource?", _

VbYesNo, "Access Denied")

If intMessage = vbYes Then

ObjShell.Run ("http://www.microsoft.com")"

Else

Wscript.Quit

End If

We first create an instance of the WSH Shell object; we need to create this instance to pop up the Web browser and link to the Web site. Then we display a message box (titled access denied) and ask the user, "do you want to request access to this resource?" This message box has a yes button and a no button, which is the purpose of the VBScript constant vbYesNo.

Note: some people may be thinking, "wait a minute, I think you should clearly define these constants in VBScript." In most cases, this is true. If we are dealing with FileSystemObject (for example), we need to define constants with code similar to the following:

Const ForReading = 1

However, VBScript has some internal constants. VbYesNo happens to be one of them. It is used to display the Yes button or No button in the message box. VbCrLf is another internal constant that adds carriage returns to the end of the string as a newline. These internal constants-- they're part of the VBScript language-- don't have to be defined; when you type vbYesNo, VBScript will know what you mean.

Where were we? Oh, by the way, we pop up a message box and provide the user with yes and no buttons. If the user clicks yes, we will take them to the designated website. So, how do you know if the user clicked yes or no? It's simple: when we create a message box, we store the user response in the variable intMessage. So to determine which button the user clicked, all we have to do is check the value of intMessage. If this value is equal to vbYesNo (another internal constant, equal to 6), then the user clicks on it, so we open the website http://www.microsoft.com using the Run method of the Shell object. Note that all we need to do is specify URL; and the operating system will navigate to the site using the default browser. )

What if the user clicks no? In this case, we will Wscript.Quit.

As we said, this method is not exactly what we imagined, but it can achieve this goal.

The above is all the contents of the article "how to use vbscript to display a hyperlink in the message box". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report