1

私に合った Visual Basic の待機コマンドが必要です。

知っている:

Declare Sub Sleep Lib "kernel32.dll" (ByVal milliseconds As Long)
sleep 5000

しかし、それはプログラムを無反応にします。

System.Threading.Thread.Sleep(5000) 'The window doesn't load until the timing is over (useless)

私のコード:

Imports Microsoft.Win32 'To check if is 64Bit or 32Bit

Public Class Loading
  Private Sub Loading_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    If Registry.LocalMachine.OpenSubKey("Hardware\Description\System\CentralProcessor\0").GetValue("Identifier").ToString.Contains("x86") Then
      My.Settings.Is64 = False
    Else
      My.Settings.Is64 = True
    End If

    'I need command here

    If My.Settings.Is64 = True Then
      Form64.Show()
      Me.Close()
    Else
      MsgBox("No version developed for 32-bit computers.")
      End
    End If
  End Sub
End Class

エラー:

@アイドルマインド

1. function 'OnInitialize' cannot be declared 'Overrides' because it does not override a function in a base class.
2.  'MinimumSplashScreenDisplayTime' is not a member of 'App.Loading.MyApplication'.
    3.  'OnInitialize' is not a member of 'Object'.
4

5 に答える 5

7

コメントから:

ここに画像の説明を入力

プロジェクトのプロパティに移動し、メイン フォームをスタートアップ フォームのままにします。スプラッシュ スクリーン フォームをスプラッシュ スクリーン エントリとして下部に設定します。次に、右側の [View Application Events] ボタンをクリックして上書きし、 MinimumSplashScreenDisplayTime()を次のようOnIntializeに設定できるようにします。

Namespace My

    ' The following events are available for MyApplication:
    ' 
    ' Startup: Raised when the application starts, before the startup form is created.
    ' Shutdown: Raised after all application forms are closed.  This event is not raised if the application terminates abnormally.
    ' UnhandledException: Raised if the application encounters an unhandled exception.
    ' StartupNextInstance: Raised when launching a single-instance application and the application is already active. 
    ' NetworkAvailabilityChanged: Raised when the network connection is connected or disconnected.
    Partial Friend Class MyApplication

        Protected Overrides Function OnInitialize(ByVal commandLineArgs As System.Collections.ObjectModel.ReadOnlyCollection(Of String)) As Boolean
            ' Set the display time to 5000 milliseconds (5 seconds). 
            Me.MinimumSplashScreenDisplayTime = 5000
            Return MyBase.OnInitialize(commandLineArgs)
        End Function

    End Class


End Namespace
于 2013-07-12T14:31:07.173 に答える
2

アプリケーションをキャンセルする場所が必要な場合は、Application.Startupイベントを使用して、e.Cancel = Trueそこから設定します。これが完了すると、メイン フォームは表示されません。アプリケーションは単に終了します。それは次のようになります。

Namespace My

    ' The following events are available for MyApplication:
    ' 
    ' Startup: Raised when the application starts, before the startup form is created.
    ' Shutdown: Raised after all application forms are closed.  This event is not raised if the application terminates abnormally.
    ' UnhandledException: Raised if the application encounters an unhandled exception.
    ' StartupNextInstance: Raised when launching a single-instance application and the application is already active. 
    ' NetworkAvailabilityChanged: Raised when the network connection is connected or disconnected.
    Partial Friend Class MyApplication

        Private Sub MyApplication_Startup(sender As Object, e As Microsoft.VisualBasic.ApplicationServices.StartupEventArgs) Handles Me.Startup
            If someCondition Then
                MessageBox.Show("oops")
                e.Cancel = True ' <-- main form will NOT show, app will simply exit
            End If
        End Sub

    End Class


End Namespace
于 2013-07-12T15:03:03.223 に答える