Adblock breaks this site

ISO MASSIVE HELP VB 08 program

Discussion in 'Programming General' started by PvMage, Dec 21, 2007.

  1. PvMage

    PvMage Guest

    Referrals:
    0
    ISO MASSIVE HELP VB 08 program

    im making a program that prime factors numbers, this is what i have

    but for some reason it will not display the factored numbers in my textbox

    If you can fix this so it works i will give u my runescape account, its a puremage, name is be0tchkillaz

    i quit runescape along time ago for WoW.

    PLEASE HELP!!!!!!!!!




    Friend Class primeFactors
    Inherits System.Windows.Forms.Form
    Private Sub start_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles start.Click

    Dim startingNumber As Double
    Dim i As Integer
    Dim temp As Double
    Dim factor As Double





    startingNumber = txtBox.Text 'read text box as double starting number
    For i = 2 To startingNumber - 1 'for loop goes from 2 to 1 less than the starting number
    If startingNumber / i = Int(startingNumber / i) Then 'if the value of i is a factor of the starting number

    factor = i 'store i as factor
    If IsPrime(factor) = True Then 'if factor is prime
    temp = startingNumber / factor 'stores temp as the starting number divided by factor

    TextBox1.Text = factor & " is a prime factor"


    While temp / factor = Int(temp / factor) 'while loop to find how many of the prime factor are in the number

    TextBox1.Text = factor & " is a prime factor"
    temp = temp / factor
    End While
    End If
    End If
    Next i

    End Sub
    Private Function IsPrime(ByRef factor As Double) As Boolean
    Dim check As Double 'Number to check
    Dim factorRoot As Double 'Square root of factor
    Dim found As Boolean 'checks for factor
    If (factor Mod 1) = 0 Then 'if it is even
    IsPrime = False 'sets the factor not prime
    Else
    factorRoot = Int(System.Math.Sqrt(factor))
    check = 3 'start with 3 because only odds need to be chacked and 1 can be discounted
    Do Until check > factorRoot Or found 'loop until the number being checked is higher than its square root
    If factor / check = Int(factor / check) Then 'if temp is an integer
    found = True 'set
    Else
    check = check + 2 'check the next odd number because evens will never be prime
    End If
    Loop
    IsPrime = Not (found)
    End If
    If factor = 2 Then '2 is a prime number
    IsPrime = True
    End If
    Exit Function

    End Function

    End Class
     
  2. Swan

    Swan When They Cry...
    Retired Global Moderator

    Joined:
    Jan 23, 2007
    Posts:
    4,957
    Referrals:
    0
    Sythe Gold:
    0
    Sythe's 10th Anniversary Member of the Month Winner
    ISO MASSIVE HELP VB 08 program

    use code boxes next time. Lack of indentation and crappy font and spacing makes it hard for me to understand your code.
     
  3. PvMage

    PvMage Guest

    Referrals:
    0
    ISO MASSIVE HELP VB 08 program

    how do i use a code box?
     
  4. PvMage

    PvMage Guest

    Referrals:
    0
    ISO MASSIVE HELP VB 08 program

    got it to work
     
  5. rattytatt50

    rattytatt50 Member

    Joined:
    Oct 26, 2007
    Posts:
    67
    Referrals:
    0
    Sythe Gold:
    0
    ISO MASSIVE HELP VB 08 program

    [ code ]
    [/ code ]
     
< Progress Bar Help | Debug loader framework >


 
 
Adblock breaks this site