Results 1 to 9 of 9

Thread: Hellp

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2007
    Posts
    26

    Hellp

    I keep getting an error messege that says :

    Conversion from string "" to type "integer" is not valid?!?!!?

    what should i do?? what am i doing wrong?




    Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles calculate.Click

    Dim thenumber, theterms, z As Integer
    Dim thesum As Decimal


    thenumber = CInt(number.Text)
    theterms = CInt(terms.Text)
    thesum = CDec(sum.Text)

    theterms = 1
    thesum = 0


    Do Until thesum > thenumber
    z = 1 / theterms
    thesum = z
    Exit Do
    z = z + z
    theterms = theterms + 1

    Loop

    terms.Text = CStr(theterms)
    sum.Text = CStr(thesum)





    End Sub
    End Class

  2. #2
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Hellp

    Dim thenumber, theterms, z As Integer
    This is an incorrect way of dimming

    Try this
    VB Code:
    1. Dim thenumber As Integer, theterms As Integer, z As Integer
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  3. #3
    Frenzied Member zynder's Avatar
    Join Date
    Nov 2006
    Location
    localhost
    Posts
    1,434

    Re: Hellp

    Exactly! You get that error because thenumber and theterms are declared as variants.
    Do what koolsid suggested.

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Feb 2007
    Posts
    26

    Re: Hellp

    i changed it around a little bit, but same problem...i get that messege



    Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles calculate.Click

    Dim thenumber As Integer
    Dim theterms As Integer
    Dim z As Integer
    Dim n As Integer
    Dim thesum As Decimal


    thenumber = CInt(number.Text)
    theterms = CInt(terms.Text)
    thesum = CDec(sum.Text)

    theterms = 1
    thesum = 0
    z = 1 / n
    n = 1



    Do While thesum < thenumber
    thesum = z
    z = z + z
    n = n + 1

    Loop



    terms.Text = CStr(theterms)
    sum.Text = CStr(thesum)

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Feb 2007
    Posts
    26

    Re: Hellp

    The sum of the series 1/1 +1/2 +1/3.... never converges. Thus if you add enough terms you can reach any value/ For example it takes 4 terms of the series to reach 2 as 1 + 1/2 +1/3 +1/4 is 2.0833333 and 11 terms to reach 3.

    AM i writing this program right???

  6. #6
    Frenzied Member zynder's Avatar
    Join Date
    Nov 2006
    Location
    localhost
    Posts
    1,434

    Re: Hellp

    I think this should be move to VB.Net however, why are you using integers? Try using double.

  7. #7
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Hellp

    theterms = 1
    thesum = 0
    z = 1 / n
    n = 1
    Have you declared the value of 'n' elsewhere before 'z = 1 / n'?
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  8. #8
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863

    Re: Hellp

    He's doubleposting the same topic! I suggest to reply only on the other one!
    The other post
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  9. #9
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Hellp

    He's doubleposting the same topic!
    lol...

    Sorry I must have missed the other post.

    @cthompson86: Please do not make duplicate threads. You will end up confusing yourself and others too... besides it is not allowed
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

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