如何自动点击按钮? [英] How to auto click button?

查看:76
本文介绍了如何自动点击按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想显示IP地址,以便我使用IP地址功能:



I want to show the IP address so i make the IP address function:

Function GetIP() As String
        Dim IP As New WebClient
        Return IP.DownloadString("http://bot.whatismyipaddress.com")
    End Function





现在,每当表单加载时,它应该自动显示IP地址,而不是手动单击按钮以显示IP地址。



我这样做了但现在正在工作





Now, whenever the form load, it should shows me the IP address automatically instead of clicking the button manually to show the IP address.

I have done something this way but now working

Private Sub Label29_Click_1(sender As Object, e As EventArgs) Handles IPAdd.Click
        Button3.PerformClick()
    End Sub

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        IPAdd.Text = GetIP()  'Label name IPAdd
    End Sub





请帮助



Please help

推荐答案

创建一个加载方法并添加一个调用来自load meth的GetIP函数od:

Create a load method and add a call to the GetIP function from the load method:
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    IPAdd.Text = GetIP()

End Sub



没有必要单击按钮。

您可能也想查看代理,因为从表单线程填充文本框通常不被认为是良好的做法。


There is no need to click the button.
You may want to look into delegates too as populating a textbox from the form thread is not generally considered good practice.


这篇关于如何自动点击按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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