我需要我的应用程序来检查用户计算机上的互联网连接.如果有,则显示图像,如果没有,则显示不同的图像.这是我用来实现这个的代码:
Private Sub Window_Loaded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles MyBase.Loaded
If NetworkInformation.NetworkInterface.GetIsNetworkAvailable Then
Dim bi1 As New BitmapImage
bi1.BeginInit()
bi1.UriSource = New Uri("Images\greenbar.png", UriKind.Relative)
bi1.EndInit()
Image2.Source = bi1
Else
Dim bi2 As New BitmapImage
bi2.BeginInit()
bi2.UriSource = New Uri("Images\redbar.png", UriKind.Relative)
bi2.EndInit()
Image2.Source = bi2
MessageBox.Show("INTERNET CONNECTION NOT DETECTED")
MessageBox.Show("You must be connected to the internet to use some aspects of this application.")
MessageBox.Show("Please re-establish connection to the Internet and try again, thank you.")
Me.Close()
End If
End …Run Code Online (Sandbox Code Playgroud) 在 PowerShell 中,如何退出嵌套在语句while内的循环switch,而不执行紧随该块之后的代码while?我似乎无法弄清楚。到目前为止我所尝试的一切都会导致该代码块被执行。
这就是我想要实现的目标:
这是代码:
try {
#Step 1
$Prompt = <Some Notification Dialog with two buttons>
switch ($Prompt){
'YES' {
# Display the Windows Control Panel
#Wait for user to manually uninstall an application - which removes a file from the path we will check later.
$Timeout = New-Timespan -Seconds 30
$Stopwatch = [Dispatch.Stopwatch]::StartNew()
while ($Stopwatch.elapsed -lt $Timeout) {
if (Test-Path -Path "C:\SomeFile.exe" -PathType Leaf) {
Write-Host …Run Code Online (Sandbox Code Playgroud) 晚上好,
我正在使用以下代码截断MySQL数据库中的表.据我所知,查询运行正常,表被截断.但是,正在使用我用于测试行是否受到影响的if语句在Else语句上进行评估.
那么为什么数据库中的表被截断 - 正如预期的那样 - 但正在评估Else语句 - 好像没有行受到影响?我究竟做错了什么?
这是代码:
Public Sub purgeCC()
Dim dbAdapter As New MySqlDataAdapter
Dim dbCmd As New MySqlCommand
Dim ConnectionString As String = String.Format("Server={0};Port={1};Uid={2};Password={3};Database=accounting", FormLogin.ComboBoxServerIP.SelectedItem, My.Settings.DB_Port, My.Settings.DB_UserID, My.Settings.DB_Password)
Dim myQuery As String = "TRUNCATE TABLE cc_master"
Using dbConn As New MySqlConnection(ConnectionString)
Using dbComm As New MySqlCommand()
With dbComm
.Connection = dbConn
.CommandType = CommandType.Text
.CommandText = myQuery
End With
Try
Dim affectedRow As Integer
dbConn.Open()
affectedRow = dbComm.ExecuteNonQuery()
If affectedRow > 0 Then
MsgBox("Credit Card …Run Code Online (Sandbox Code Playgroud)