帮助"复制链接位置“在我的网络浏览器中 [英] Help " Copy link location " in my web browser

查看:103
本文介绍了帮助"复制链接位置“在我的网络浏览器中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨〜
你好..?

我是新来的程序员.

我有一个我无法解决的小问题..我尝试提出问题,并搜索了所有网络,但没有任何结果..

我的问题是我在vb.net中制作了一个Web浏览器程序
并且我想制作一个ToolStripMenuItem,当我单击它时,将链接位置复制到剪贴板,以便可以将其粘贴到该位置的url之类的组合框中.
我写了这段代码

*

Hi ~
how are you.. ?

I''m a new programmer..

I have a little problem that I can''t solve it.. I try to ask and I search all the web but without any result..

My problem is that I made a web browser program in vb.net
and I want to make a ToolStripMenuItem that when I click it copy the link location to clipboard and so I can past it into combobox like url for that location..

I wrote this code

*

Private oElement As HtmlElement





Private Sub ToolStripMenuItem13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem13.Click
     Clipboard.SetText(oElement.GetAttribute("HREF"))
 End Sub





但是它没有用..告诉我错误..

请帮助我〜





but it didn''t work.. show me error..

please Help me ~

推荐答案

OK,这样您就可以得到一个空引用,这意味着您正在尝试使用尚未初始化的对象引用.不幸的是,您的图片中的对话框使令人讨厌的代码行变得晦涩难懂,但是,您可能猜中了该行:
OK so you have a null reference, which means that you are trying to use an object reference that has not been initialised. Unfortunately your picture has the dialog obscuring the offending line of code, but, at a guess it is in the line:
Clipboard.SetText(oElement.GetAttribute("HREF"))


那么,oElement是从哪里来的?它指向什么呢?


So, where does oElement come from and what does it point to?


是的.
Public Class frmBrowser

    Public WithEvents oDoc As HtmlDocument
    Private oElement As HtmlElement



它指向HtmlElement.
您知道吗,就像我想告诉他,您必须复制指针所在的链接.



and it point to HtmlElement.
you know, like I want to tell him that you have to copy the link that the pointer is on it.


这篇关于帮助"复制链接位置“在我的网络浏览器中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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