ISO MASSIVE HELP VB 08 program

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

ISO MASSIVE HELP VB 08 program
  1. Unread #1 - Dec 21, 2007 at 12:04 AM
  2. PvMage
    Referrals:
    0

    PvMage Guest

    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
     
  3. Unread #2 - Dec 21, 2007 at 12:09 AM
  4. Swan
    Joined:
    Jan 23, 2007
    Posts:
    4,957
    Referrals:
    0
    Sythe Gold:
    0
    Sythe's 10th Anniversary Member of the Month Winner

    Swan When They Cry...
    Retired Global Moderator

    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.
     
  5. Unread #3 - Dec 21, 2007 at 12:11 AM
  6. PvMage
    Referrals:
    0

    PvMage Guest

    ISO MASSIVE HELP VB 08 program

    how do i use a code box?
     
  7. Unread #4 - Dec 21, 2007 at 1:14 AM
  8. PvMage
    Referrals:
    0

    PvMage Guest

    ISO MASSIVE HELP VB 08 program

    got it to work
     
  9. Unread #5 - Dec 21, 2007 at 8:24 AM
  10. rattytatt50
    Joined:
    Oct 26, 2007
    Posts:
    67
    Referrals:
    0
    Sythe Gold:
    0

    rattytatt50 Member

    ISO MASSIVE HELP VB 08 program

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

Users viewing this thread
1 guest


 
 
Adblock breaks this site