Results 1 to 14 of 14

Thread: Coding problem

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2015
    Posts
    5

    Coding problem

    Dear All,


    S.No. Input Input Output
    1 A B A*B
    2 A B A*B
    3 A B A*B
    4 A B A*B
    5 A B A*B
    Sum(1+2+3+4+5)

    Can you suggest the coding in VB??
    Last edited by Vin7743; Jan 6th, 2015 at 06:26 AM.

  2. #2
    Super Moderator FunkyDexter's Avatar
    Join Date
    Apr 2005
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    7,957

    Re: Coding problem

    Do you have a question?
    The best argument against democracy is a five minute conversation with the average voter - Winston Churchill

    Hadoop actually sounds more like the way they greet each other in Yorkshire - Inferrd

  3. #3
    Superbly Moderated NeedSomeAnswers's Avatar
    Join Date
    Jun 2002
    Location
    Manchester uk
    Posts
    2,657

    Re: Coding problem

    This post gets my vote as the best question for 2015 .... and we are only 5 days in!

    More seriously though your post read a bit like this

    "Morning I am trying to build a spaceship

    bluetack
    cardboard
    sequines

    Thanks"

    Maybe you should read this
    Please Mark your Thread "Resolved", if the query is solved & Rate those who have helped you



  4. #4

    Thread Starter
    New Member
    Join Date
    Jan 2015
    Posts
    5

    Re: Coding problem

    Dear all,

    I want in promgram in which the input value is A and B and outpu tvalue is Multiple of A and B (A*B) and sum of output

    S.No. Input Input Output
    1 A B A*B
    2 A B A*B
    3 A B A*B
    4 A B A*B
    5 A B A*B
    Sum(1+2+3+4+5)

    Can you suggest the coding in VB ????

  5. #5
    Superbly Moderated NeedSomeAnswers's Avatar
    Join Date
    Jun 2002
    Location
    Manchester uk
    Posts
    2,657

    Re: Coding problem

    have you got your supply of sequins yet? What about blue-tack?

    because there is no way we can help you build your spaceship without them !!
    Please Mark your Thread "Resolved", if the query is solved & Rate those who have helped you



  6. #6
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Coding problem

    Vin - you need to provide a CLEAR and accurate description of what you're trying to do. Please keep in mind we are not clairvoyant, nor are we sitting in your lap, so we only know what you're telling us. And at this point, it isn't very much. There's no context to the problem at hand. Is it in a database? Is this in a loop? How are you getting the data? Is it in a datatable? Is it in a text file? Is it in 15 different variables? And array? The answer on how to solve the problem is going to depend on things like that. So far, all you've managed to do is walk into the mechanic's shop, point at your car and say "It broke. It no worky worky." There's no context as to what the problem is (you drove your car in to a tree! - of course it's not going to work!)

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  7. #7
    Hyperactive Member
    Join Date
    Mar 2012
    Posts
    311

    Re: Coding problem

    I think I have a very basic grasp of what Vin is asking for, but still not much. If I understand correctly, the user will be inputting two numbers (input how? and what data-type?) A and B (may want more expressive names). The program will then get a product of those two numbers and display this as output (in what way? MessageBox? Form control? Console output?). Additionally, there is to be the sum of all products also outputted (Continuous looping until an exit code is entered by user? A specific number of products? Or just keep a running tally each time a new product of numbers is requested?). However as you can see even with my questions, there is still a lot of unknowns... Even some context might make it a little easier to understand. Are you trying to write a shopping cart type of program where A is the quantity, B is the unit price, and the sum is the total cost of the order?

    Moreover, this forum is for help with specific questions about a specific piece of code. We are not being paid, so we do not write other's code for them. So even if all of these questions are answered, we still have not been shown any code to see where you are going wrong, and we are not here to build a complete project from scratch.

  8. #8
    PowerPoster i00's Avatar
    Join Date
    Mar 2002
    Location
    1/2 way accross the galaxy.. and then some
    Posts
    2,390

    Re: Coding problem

    Do you mean:

    You want to enter the values of:
    A1, B1
    A2, B2
    A3, B3
    A4, B4
    A5, B5

    Then do this?
    Sum((A1*B1)+(A2*B2)+(A3*B3)+(A4*B4)+(A5*B5))

    Kris

  9. #9

    Thread Starter
    New Member
    Join Date
    Jan 2015
    Posts
    5

    Re: Coding problem

    Dear Pythoo7,

    hi,

    Thanks for your understanding, your are absolutly right i ma trying to writh shoppig cart promgram in which A is Qty and B is Untiprice and the sum is = Total , in addition of my query is i want 5 to 10 items in a row and the sum of all items totals

    I am make the program in VB 2010 and for database i used SQL server , my problem it is working ok for single itemsBut I need in 5 - 10 items in a row

    Can you give any suggestion

    Vin

  10. #10

    Thread Starter
    New Member
    Join Date
    Jan 2015
    Posts
    5

    Re: Coding problem

    Kris,

    Thanks for your understanding, your are absolutly right i ma trying promgram in which A is Qty and B is Untiprice and the sum is = Total , in addition of my query is i want 5 to 10 items in a row and the sum of all items totals

    I am make the program in VB 2010 and for database i used SQL server , my problem it is working ok for single itemsBut I need in 5 - 10 items in a row

    Can you give any suggestion??

    Vin

  11. #11

    Thread Starter
    New Member
    Join Date
    Jan 2015
    Posts
    5

    Re: Coding problem

    hi,
    I want to enter the values of:
    A1, B1
    A2, B2
    A3, B3
    A4, B4
    A5, B5

    And then the sum of all
    Sum((A1*B1)+(A2*B2)+(A3*B3)+(A4*B4)+(A5*B5))

    Is it clear for you?

  12. #12
    Superbly Moderated NeedSomeAnswers's Avatar
    Join Date
    Jun 2002
    Location
    Manchester uk
    Posts
    2,657

    Re: Coding problem

    Is it clear for you?
    Yes & No !

    Vin we already understood the logic problem, that is not what everyone has been trying to get through to you!

    Post your code !!!!
    Please Mark your Thread "Resolved", if the query is solved & Rate those who have helped you



  13. #13
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Coding problem

    The logic is fine... and only part of the issue... but we also need to know how the data is entered and stored... I can give you a SQL solution, but unless the data is in a table in a database, the solution is useless.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  14. #14
    Hyperactive Member
    Join Date
    Sep 2014
    Posts
    404

    Re: Coding problem

    can I suggest you either make a custom control.
    With the following properties:

    -Quantity (Self Explanatory)
    -Unit Price (Self Explanatory)

    -TotalPrice (readonly)
    Get
    Return Me.UnitPrice * Me.Quantity
    End Get

    then to get a total do the following
    Dim running_total as decimal

    for each control in me. controls if typeof control is Custom Type then
    running_total += control.TotalPrice
    next
    Last edited by Leary222; Jan 9th, 2015 at 04:54 PM. Reason: missed information

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