home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Object = "{3B7C8863-D78F-101B-B9B5-04021C009402}#1.1#0"; "RICHTX32.OCX"
- Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.3#0"; "COMCTL32.OCX"
- Begin VB.Form Primer
- BorderStyle = 1 'Fixed Single
- Caption = "Primer"
- ClientHeight = 3135
- ClientLeft = 1980
- ClientTop = 1440
- ClientWidth = 4215
- ClipControls = 0 'False
- Icon = "Primer3.frx":0000
- LinkTopic = "Form1"
- MaxButton = 0 'False
- MousePointer = 1 'Arrow
- PaletteMode = 1 'UseZOrder
- Picture = "Primer3.frx":0442
- ScaleHeight = 3135
- ScaleWidth = 4215
- Begin RichTextLib.RichTextBox Primes
- Height = 1455
- Left = 0
- TabIndex = 6
- Top = 600
- Width = 4215
- _ExtentX = 7435
- _ExtentY = 2566
- _Version = 393217
- ScrollBars = 2
- DisableNoScroll = -1 'True
- TextRTF = $"Primer3.frx":0884
- End
- Begin ComctlLib.ProgressBar PB
- Height = 255
- Left = 0
- TabIndex = 4
- Top = 2880
- Width = 4215
- _ExtentX = 7435
- _ExtentY = 450
- _Version = 327682
- Appearance = 1
- End
- Begin VB.CommandButton Command1
- Caption = "&Copy"
- Height = 375
- Left = 2880
- TabIndex = 3
- Top = 2160
- Width = 1335
- End
- Begin VB.CommandButton cmdStop
- Caption = "&Stop"
- Height = 375
- Left = 1440
- TabIndex = 1
- Top = 2160
- Width = 1335
- End
- Begin VB.CommandButton cmdStart
- Caption = "&Start"
- Default = -1 'True
- Height = 375
- Left = 0
- TabIndex = 0
- Top = 2160
- Width = 1335
- End
- Begin VB.Label lblStat
- BackStyle = 0 'Transparent
- Height = 255
- Left = 0
- TabIndex = 5
- Top = 2640
- Width = 4215
- End
- Begin VB.Label lblDir
- BackStyle = 0 'Transparent
- Caption = "Press start to view the prime numbers."
- Height = 255
- Left = 600
- TabIndex = 2
- Top = 120
- Width = 3495
- End
- Attribute VB_Name = "Primer"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Dim PrimeOn As Boolean
- Dim P As New Collection
- Dim H As New Collection
- Dim S As String
- Sub Prime()
- Static A As Long, B As Long, C As Long
- Dim D As String, E As Long, i As Integer
- lblDir = "Calculating..."
- For i = 1 To P.Count
- P.Remove 1
- Next i
- Primes = ""
- D = InputBox("Type in the maximum prime number:")
- If D = "" Then Exit Sub
- E = Val(Right(D, 7))
- If E Mod 2 = 0 Then E = E - 1
- PB.Min = 0
- PB.Max = E
- Ad 2
- For A = 3 To E Step 2
- DoEvents
- PB.Value = A
- If Not PrimeOn Then PrimeOn = True: Exit Sub
- For B = 1 To P.Count
- If P.Item(B) > Sqr(A) Then
- Ad (A): Exit For
- End If
- If A Mod P.Item(B) = 0 Then Exit For
- Next B
- lblStat = "Status -- " & Prc(PB.Max, PB.Value)
- Caption = "Primer - " & Prc(PB.Max, PB.Value)
- Next A
- lblStat = "": PB.Value = 0
- PB.Max = P.Count
- lblDir = "Acquiring primes. Please wait."
- For C = 1 To P.Count
- If Not PrimeOn Then PrimeOn = True: Exit Sub
- Primes.SelStart = Len(Primes) - 1
- Primes.SelText = CStr(P.Item(C)) & vbCrLf
- PB.Value = C
- lblStat = "Printing - " & Prc(PB.Max, PB.Value)
- Caption = "Primer - " & Prc(PB.Max, PB.Value)
- Next C
- lblStat = "": PB.Value = 0
- Caption = "Primer"
- lblDir = "Complete. Click the Copy button to send primes to clipboard."
- Exit Sub
- End Sub
- Function Prc(ByVal Mx As Long, ByVal Vl As Long) As String
- Prc = (1 / (Mx / Vl) * 100) \ 1 & "%"
- End Function
- Private Sub cmdStart_Click()
- Dim i As Integer
- For i = H.Count To 1 Step -1
- H.Remove (i)
- Next i
- S = "Priming"
- PrimeOn = True
- Prime
- End Sub
- Private Sub cmdStop_Click()
- S = "Copying"
- PrimeOn = False
- End Sub
- Private Sub Command1_Click()
- Dim i As Double, Tex As String
- PrimeOn = True
- PB.Max = P.Count
- PB.Min = 0
- For i = 1 To P.Count
- DoEvents
- PB.Value = i
- If Not PrimeOn Then Exit Sub
- Tex = Tex & ", " & P.Item(i)
- Caption = "Primer - " & P.Item(i) & "; " & Prc(PB.Max, PB.Value)
- lblStat = "Copying to Clipboard - " & Prc(PB.Max, PB.Value)
- Next i
- PB.Value = 0
- lblStat = ""
- Clipboard.SetText Tex, &HBF01
- Clipboard.SetText Tex, 1
- Caption = "Primer"
- PB.Value = 0
- lblStat = ""
- End Sub
- Function Ad(ByVal Amt As Long)
- P.Add (Amt)
- Foo Amt
- End Function
- Public Function Foo(ByVal Number As Long) As Long
- Dim Word As String, SizeNum As Integer, i As Integer, j As Integer
- Dim Temp As String, Add As Long
- Word = Str(Number)
- SizeNum = Len(Word)
- For i = 1 To SizeNum
- j = SizeNum - i
- Temp = Left(Right(Word, j), i)
- Add = Add + Val(Left(Temp, 1))
- Next i
- H.Add Add
- End Function
- Private Sub lblStat_Click()
- Dim i As Integer, St As String
- Primes.Text = ""
- For i = 1 To H.Count
- If H.Item(i) Mod 2 = 0 Then St = St & H(i) & " "
- DoEvents
- Debug.Print i
- Next i
- Clipboard.SetText St, &HBF01
- Clipboard.SetText St, 1
- End Sub
- '''''''''''''''''''''''''
- ' 1 999 999 6 '
- ' 1 1 9 9 9 9 6 '
- ' 1 9999 9999 6666 '
- ' 1 9 9 6 6 '
- ' 11111 9 9 666 '
- '''''''''''''''''''''''''
- ' Feucht Production '
- '''''''''''''''''''''''''
-