Visual Basic


Home

About the Author

General Programming

Pascal

Delphi

C&C++

Visual Basic

SQL

JAVA Script

Links

 

Math

A fast Prime number checker

Misc

Screensaver

Any questions send them to vb@teentwo.8m.com


A fast Prime number checker

Function IsPrime(lngNumber As Long) As Boolean
    Dim lngFactor As Long IsPrime = True
    lngFactor = Abs(Sqr(lngNumber))
    If lngNumber <> 2 Then
          If lngNumber Mod 2 = 0 Then
            IsPrime = False
          Else
            For lngFactor = 3 To lngFactor Step 2
              If lngNumber Mod lngFactor = 0 Then
                IsPrime = False
                Exit For
              End If
            Next 
          End If
    End if
End Function

Any questions send them to vb@teentwo.8m.com


A rather irritating screensaver thingy...

Public Function RandomNum(Min, Max) As Long
     RandomNum = Int((Max - Min + 9500) * Rnd + Min)
End Function

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
     Unload Me
End Sub

Private Sub Form_KeyPress(KeyAscii As Integer)
     Unload Me
End Sub

Private Sub Form_Load()
     Form1.BackColor = vbBlack
     Form1.BorderStyle = 0
     Timer1.Interval = 175
End Sub

Private Sub Timer1_Timer()
     Form1.BackColor = RandomNum(1, 15)
     ht = RandomNum(Min, Max)
     wh = RandomNum(Min, Max)
     Form1.Move wh, ht
     Form1.Height = ht
     Form1.Width = wh
     Form1.Height = wh
     Form1.Width = ht
End Sub

Any questions send them to vb@teentwo.8m.com

Link of the week 
http://www.cpp-
programming.
com/
Newsgroups
comp.lang.c
comp.lang.c++
comp.programming

This page is best viewed in 800x600x256. This page was last edited Sunday, July 16, 2000

1