当前位置:首页 > 心得日志 > 正文
作者

VB 在label标签中显示远程文本广告

扫描二维码分享到朋友圈

大家知道在QQ上左下角都会有滚动的广告,一定也想在自己软件中实现此功能。刚在网上搜了一通,居然只有一个,代码还不全,说需要可以联系出售,要500块钱、太黑了。研究了一下发现自己也能实现。如下图:

image

image

自动加载远程链接,进行更换。5秒一次。并且点击后可以打开网址。

现代码公布如下:

需添加控件timer,webbrowser,label

    Private Sub Form_Load()
    Webad.Navigate "http://www.wooaii.com/suo-you-wen-zhang-lie-biao"
    Label2.Visible = False
Timer1.Interval = 1000
i = 0
   li = -1
End Sub

Private Sub Timer1_Timer()
i = i + 1

              If i = 5 Then
              Label2.Visible = True

              li = li + 1

                If Webad.Document.links.Item(li) <> S Then
                   Label2.Caption = Webad.Document.links.Item(li).innertext
                End If
                 i = 0
               End If
If li = Webad.Document.links.length – 1 Then
li = 0
End If

End Sub

webad即webbrowser控件。label2用来显示广告。两个变量i和li开始运行即加载远程网页。label2设为不可见。i=0 li=-1(发现li设为-1时才可以显示最新一条)

然后每5秒换一条。

如果Webad.Document.links.Item(li) <> S 标签就显示某条文本。这个S是个空值。

Private Sub Label2_Click()
res = ShellExecute(0, vbNullString, Webad.Document.links.Item(li).href, vbNullString, vbNullString, SW_SHOWNORMAL)
End Sub

 

点击label2即用默认浏览器打开链接。默认浏览器代码不再多说。



591 条评论

  1. 9楼2017-01-08 上午 2:59回复
    Wokani Dexo

    I’m partial to blogs and i actually respect your content. The article has actually peaks my interest. I am going to bookmark your site and preserve checking for new information.

  2. 8楼2017-01-15 上午 8:31回复
    online graduate

    This is one awesome post.Thanks Again.

  3. 7楼2017-01-19 下午 3:21回复
    best video seo company

    Have you ever considered creating an ebook or guest authoring on other websites? I have a blog centered on the same subjects you discuss and would love to have you share some stories/information. I know my subscribers would enjoy your work. If you are even remotely interested, feel free to shoot me an e mail.

  4. 6楼2017-01-23 下午 11:49回复
    birth injury lawyers

    This is one awesome blog article.Really thank you! Will read on…

  5. 5楼2017-01-24 上午 12:31回复
    macbeautysa

    cheap mac cosmetics wholesale product cheap makeup sites cheap makeup store online cheapest mac makeup online,mac makeup sets uk mac makeup online cheap mac makeup brush set wholesalefree delivery shopping online.

  6. 4楼2017-01-24 上午 3:43回复
    processing debit cards

    I appreciate you sharing this blog article.Really thank you! Want more.

  7. 地板2017-01-24 上午 7:43回复
    paprika

    Thank you for your article post.Much thanks again. Really Cool.

  8. 板凳2017-01-24 上午 11:38回复
    poker party net

    Enjoyed every bit of your blog post.Much thanks again. Awesome.

  9. 沙发2017-01-24 下午 3:33回复
    san diego accident

    This is one awesome blog article.Really thank you! Will read on…

发表评论


无觅相关文章插件,快速提升流量