MessageBox的公共功能帮助 [英] Public Function Help with MessageBox

查看:45
本文介绍了MessageBox的公共功能帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以帮助我理解为什么此功能不显示我的消息框吗?该功能除了

Can someone help me understand why this function doesn't show my message box? The function works all besides the

MessageBox.Show("Apple Mobile Device USB Driver = True", "My Application",
           MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk)

谢谢.

Public Function IsUserlandConnected()
        Dim forever As Boolean = True
        Dim USBName As String = String.Empty
        Dim USBSearcher As New ManagementObjectSearcher(
                  "root\CIMV2",
                  "SELECT * FROM Win32_PnPEntity WHERE Description = 'Apple Mobile Device USB Driver'")
        For Each queryObj As ManagementObject In USBSearcher.Get()
            USBName += (queryObj("Description"))
        Next
        If USBName = "Apple Mobile Device USB Driver" Then
            Return True
            MessageBox.Show("Apple Mobile Device USB Driver = True", "My Application",
           MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk)
        Else
            Return False
            MessageBox.Show("Apple Mobile Device USB Driver = False", "My Application",
           MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk)
        End If
    End Function

推荐答案

仍然无效吗?我尝试删除

Still doesn't work? I tried removing

Return True

Return False

但是它仍然不起作用..我也尝试了这个.

but it still doesn't work.. I also tried this.

Public Function IsUserlandConnected()
        Dim forever As Boolean = True
        Dim USBName As String = String.Empty
        Dim USBSearcher As New ManagementObjectSearcher(
                  "root\CIMV2",
                  "SELECT * FROM Win32_PnPEntity WHERE Description = 'Apple Mobile Device USB Driver'")
        For Each queryObj As ManagementObject In USBSearcher.Get()
            USBName += (queryObj("Description"))
        Next
        If USBName = "Apple Mobile Device USB Driver" Then
            Return True
            If IsUserlandConnected.Equals(True) Then
                MessageBox.Show("Apple Mobile Device USB Driver = True", "My Application",
           MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk)
            End If
        Else
            Return False
            If IsUserlandConnected.Equals(False) Then
                MessageBox.Show("Apple Mobile Device USB Driver = False", "My Application",
           MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk)
            End If
        End If
    End Function


这篇关于MessageBox的公共功能帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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