📄 modmain.bas
字号:
Attribute VB_Name = "ModMain"
' -------------------------------------
' VB2Cpp - Visual Basic to C++ translator.
' Copyright (C) 2002-2003 Franck Charlet.
'
' VB2Cpp is free software; you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by
' the Free Software Foundation; either version 2, or (at your option)
' any later version.
'
' VB2Cpp is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' GNU General Public License for more details.
'
' You should have received a copy of the GNU General Public License
' along with VB2Cpp; see the file Copying.txt. If not, write to
' the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
' Boston, MA 02111-1307, USA.
' -------------------------------------
' Example 2
' Calc prime numbers
' -------------------------------------
Option Explicit
Public Const SIZE = 100
Public Const RUNS = 100
Public Declare Function GetTickCount Lib "kernel32" () As Long
Public Sub Main()
Dim flags(SIZE) As Byte
Dim i As Integer
Dim n As Integer
Dim k As Integer
Dim count As Integer
Dim iter As Integer
Dim CountTimer As Long
CountTimer = GetTickCount
For i = 0 To SIZE Step 1
flags(i) = 1
Next
For iter = 0 To RUNS Step 1
For n = 0 To SIZE Step 1
count = 0
For i = 2 To SIZE Step 1
If flags(i) = 1 Then
For k = 2 * i To SIZE Step i
flags(k) = 0
Next
End If
count = count + 1
Next
Next
Next
MsgBox CStr(count) & " primes calculated in " & CStr(GetTickCount - CountTimer) & " milliseconds.", vbInformation + vbOKOnly, "VBToLC6 Example 2"
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -