Results 1 to 23 of 23

Thread: [RESOLVED] Going beyond the assignment

Threaded View

  1. #16

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2012
    Location
    Florida
    Posts
    285

    Re: Going beyond the assignment

    vb.net Code:
    1. Imports System.Drawing
    2. Imports System.Numerics
    3. Public Class Form1
    4.     Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
    5.         TextBox1.Text = SumOfIntegers(BigInteger.Parse(TextBox1.Text)).ToString
    6.     End Sub
    7.     Public Function SumOfIntegers(ByVal int As BigInteger) As BigInteger
    8.         Dim bsum As BigInteger = 0
    9.         For i As BigInteger = 1 To int
    10.             bsum += i
    11.         Next
    12.         Return bsum
    13.     End Function
    14. End Class

    Thank you, this works.... But, the performance when I use the value of 1200500200 to start the Function, is very poor. Much slower than I would have expected. Through using breakpoints I have discovered that this line is the slowing cause

    vb.net Code:
    1. bsum += i

    Would a BGW make this maybe a little faster? I have an i7 clocking at 2.8ghz right now.
    Last edited by thebuffalo; Sep 24th, 2012 at 04:40 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width