如何使用按钮打开网址 [英] How can I open a url using a button

查看:91
本文介绍了如何使用按钮打开网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过点击一个按钮打开一个网址。

我尝试了什么

Dim url As String =https://www.google。 com



Dim omyURI As Uri

omyURI = New Uri(Url)



返回(omyURI)





网址在5个新浏览器中开放5次。



我的尝试:



Dim url As String =https://www.google。 com



Dim omyURI As Uri

omyURI = New Uri(Url)



返回(omyURI)





如何限制它在一个浏览器中打开它?

I am trying to open a url by clicking on a button .
what i have tried
Dim url As String = "https://www.google.com"

Dim omyURI As Uri
omyURI = New Uri(Url)

Return (omyURI )


The url is opening 5 times in 5 new browsers.

What I have tried:

Dim url As String = "https://www.google.com"

Dim omyURI As Uri
omyURI = New Uri(Url)

Return (omyURI )


How to restrict it to open one it in one browser?

推荐答案

该代码本身不会打开任何东西 - 它只是将一个URL作为字符串返回到您调用它的任何方法,并且将使用该字符串打开URL,可能是通过 Process.St art 方法。



我首先在Return语句上放置一个断点,然后在调试器中运行你的代码。当它到达断点时,它将停止,您可以使用调用堆栈窗格追溯代码以查看它对字符串执行的操作。几乎可以肯定的是,你在某个地方循环调用contains方法。



对不起,我们不能为你做任何 - 我们无法访问你的机器或你的源代码!





BTW:如果这是一个与web相关的项目,请注意VB代码在服务器上运行,不是客户端 - 所以浏览器将在服务器上打开。它可能看起来在开发中工作,因为这两台机器是同一台机器,但是当它们在KM上可能有数千台时,它肯定会在生产中失败!
That code in itself won't open anything - it just returns a URL as a string to whatever method you are calling it from, and that will use the string to open the URL, probably via the Process.Start method.

I'd start by putting a breakpoint on the Return statement, and running your code in the debugger. When it hits the breakpoint, it will stop, and you can use the Call Stack pane to trace back through your code to see what it is doing with the string. Almost certainly, you are calling the containing method in a loop somewhere.

Sorry, but we can't do any of that for you - we have no access to your machine or your source code!


BTW: If this is a web related project, be aware that VB code runs on the server, not the client - so the browser will open on the server. It may appear to work in dev because the two are the same machine, but it most definitely will fail in production when they are potentially thousands on KM apart!


这篇关于如何使用按钮打开网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆