演算子速度


VB Tips And Sample(HOME)(戻る)



'結論 If x <> 0 Then の方が速い。
’フォームへ
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   3090
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   4680
   LinkTopic       =   "Form1"
   ScaleHeight     =   3090
   ScaleWidth      =   4680
   StartUpPosition =   3  'Windows の既定値
   Begin VB.CommandButton Command1 
      Caption         =   "速度"
      Height          =   495
      Left            =   2880
      TabIndex        =   0
      Top             =   1920
      Width           =   1215
   End
   Begin VB.Label Label1 
      Height          =   555
      Left            =   1020
      TabIndex        =   1
      Top             =   900
      Width           =   2175
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Sub Command1_Click()
Dim x As Long
Dim ti As Long

    Label1.Caption = "計測中"
    DoEvents
    ti = timeGetTime
    x = 19000000
    Do Until x = 0
 
'                If x <> 0 Then ' 122こっちの方が速い
'
'                End If


                If Not x = 0 Then '136

                End If

          x = x - 1
    Loop
    
    ti = timeGetTime - ti
    Label1.Caption = ti & "所要時間"


End Sub




’標準モジュールへ
Attribute VB_Name = "Module1"
Option Explicit

Public Declare Function timeGetTime Lib "winmm.dll" () As Long





VB Tips And Sample(HOME)(戻る)