Results 1 to 11 of 11

Thread: Annoying Zero VB 2010

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2010
    Posts
    11

    Unhappy Annoying Zero VB 2010

    Thank you all for your help:

    My program is running great with one little problem, it keep adding a zero to my listbox and the multiplication and sum result don't line up well. Heeeeelp. the result would be like:

    1X0 = 0 <==== The Problem
    1X1 = 0
    1X2 = 1
    1X3 = 2

    ===============new code===============================


    Dim numeroMulti, numeroSuma As Integer

    'data enter by user
    numeroMulti = CDbl(TextBox1.Text)
    numeroSuma = CDbl(TextBox1.Text)


    'line of code to call modul tmultiSuma
    Call tmultiSuma(numeroMulti, numeroSuma)

    End Sub
    Public Sub tmultiSuma(ByVal numeroMulti As Integer, ByVal numeroSuma As Integer)
    Dim tMulti, tSuma, tCounter As Integer

    'loop to calculat sum and multiplication table

    Do Until tCounter = 13
    'lista resultado multiplicacion
    ListBox1.Items.Add(tCounter & "X" & numeroMulti & "=" & "" & tMulti)

    'lista resultado suma
    ListBox2.Items.Add(tCounter & "+" & numeroSuma & "=" & "" & tSuma)

    'operation with a counter
    tMulti = tCounter * numeroMulti
    tSuma = tCounter + numeroSuma
    tCounter = tCounter + 1
    Loop

  2. #2
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    Re: Annoying Zero VB 2010

    You posted in the wrong section. this is for VB Classic not .Net. I've notified Mods to move the thread for you.

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2010
    Posts
    11

    Re: Annoying Zero VB 2010

    thank you, I already post it in vb.net, thank you for advising me.

  4. #4
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    Re: Annoying Zero VB 2010

    Your problem is that you are first adding items to the listbox and then doing the calculations. It should be the other way around.

  5. #5

    Thread Starter
    New Member
    Join Date
    Oct 2010
    Posts
    11

    Re: Annoying Zero VB 2010

    can you post the code, is my first program in visual basic and I thing this is as far as I can go, it would be of great help. thank you.

  6. #6
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    Re: Annoying Zero VB 2010

    Move the .Add functions to the end of the loop.

  7. #7

    Thread Starter
    New Member
    Join Date
    Oct 2010
    Posts
    11

    Re: Annoying Zero VB 2010

    like this


    Do Until tCounter >= 13

    'operacion con counter
    tMulti = tCounter * numeroMulti
    tSuma = tCounter + numeroSuma
    tCounter = tCounter + 1

    ListBox1.Items.Add(numeroMulti & "X" & tCounter & "=" & "" & tMulti) 'lista resultado multiplicacion
    ListBox2.Items.Add(numeroSuma & "+" & tCounter & "=" & "" & tSuma) 'lista resultado suma

    Loop

    is still showing the extra zero in the result, man I'm done, is too hard.

  8. #8
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    Re: Annoying Zero VB 2010

    Try

    Code:
    Do Until tCounter >= 13
       tCounter = tCounter + 1
       
       'operacion con counter
       tMulti = tCounter * numeroMulti
       tSuma = tCounter + numeroSuma
    
       ListBox1.Items.Add(numeroMulti & "X" & tCounter & " = " & tMulti) 'lista resultado multiplicacion
       ListBox2.Items.Add(numeroSuma & "+" & tCounter & " = " & tSuma) 'lista resultado suma
    Loop

  9. #9

    Thread Starter
    New Member
    Join Date
    Oct 2010
    Posts
    11

    Re: Annoying Zero VB 2010

    jajajajaj, Thanks baja_yu it work, you are amazing, my first program an is running great thank to you, thank, thank, thank, thank, thank for your help, I appreciate it a lot.
    THANKS!!!!!!!!!!!!!!!!.

  10. #10
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    Re: Annoying Zero VB 2010

    No problem.

    As you feel your question has been answered, please take time to mark the thread as Resolved. You can do so by going to the Thread Tools menu, which is on the right side above your original post, and choosing Mark Thread Resolved.

  11. #11

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