Results 1 to 14 of 14

Thread: A small program

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2013
    Posts
    19

    A small program

    Hi to all in this forum,
    I just started here and i'm little confused with to many articles!
    I don't know where i can Post my question so if i made a mistake please move my Post to other topic.

    my question :
    I have some maths to do with three numbers : a*0.15 + b*0.5 + c*0.3 = ??
    how i can make one program with Visual Studio Express 2012 where the three numbers (0.15 , 0.5 and 0.3) will be at the background and the user (me) to enter the three numbers (a,b,c) so that gives me result ??
    the program maybe look like this and i need to press from keyboard only the three number a, b, c

    I'm not a programmer please don't be lough about this

    Thanks in advance

    Name:  prog.jpg
Views: 228
Size:  14.5 KB

  2. #2
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: A small program

    You mention you are using Visual Studios 2012 but which language VB or C#?
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jan 2013
    Posts
    19

    Re: A small program

    i need to use Visual Basic as a language for that program

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

    Re: A small program

    Moved from General Discussion / Chit Chat
    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

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

    Re: A small program

    So A B & C would be textboxes ... and the other numbers & symbols would be labels... just add as many as you need and place them accordingly.

    -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??? *

  6. #6
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,104

    Re: A small program

    You actually drew out the design fairly well. The rectangles may all be textboxes. The + and = signs would have to be in labels. You may also want a, b, and c to be labels, as well. Generally, a textbox is a place where a user can type something, but for a, b, and c, you don't really want the user to be able to type anything, right? If they are not allowed to edit the numbers in those boxes, then you should use labels rather than textboxes. In either case, fiddle around with the font, backcolor, forecolor, appearance, and borders to make them look the way you want.

    Behind the scenes, you'd want three variables (possibly called a, b, and c) of type Double. Those would hold the values. Thus you might write:

    Dim a As Double = 0.15
    Dim b As Double = 0.5
    Dim c As Double = 0.3

    you would show these variables in the textboxes/labels with something like this:

    <your control name here>.Text = a.ToString
    <your next control name here>.Text = b.ToString
    <your next control name here>.Text = c.ToString

    What happens after that isn't so clear, though, as I'm not sure what step you would want the user to take next. Do they enter a value for the total and press a button?
    My usual boring signature: Nothing

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Jan 2013
    Posts
    19

    Re: A small program

    Quote Originally Posted by Shaggy Hiker View Post
    You actually drew out the design fairly well. The rectangles may all be textboxes. The + and = signs would have to be in labels. You may also want a, b, and c to be labels, as well. Generally, a textbox is a place where a user can type something, but for a, b, and c, you don't really want the user to be able to type anything, right? If they are not allowed to edit the numbers in those boxes, then you should use labels rather than textboxes. In either case, fiddle around with the font, backcolor, forecolor, appearance, and borders to make them look the way you want.

    Behind the scenes, you'd want three variables (possibly called a, b, and c) of type Double. Those would hold the values. Thus you might write:

    Dim a As Double = 0.15
    Dim b As Double = 0.5
    Dim c As Double = 0.3

    you would show these variables in the textboxes/labels with something like this:

    <your control name here>.Text = a.ToString
    <your next control name here>.Text = b.ToString
    <your next control name here>.Text = c.ToString

    What happens after that isn't so clear, though, as I'm not sure what step you would want the user to take next. Do they enter a value for the total and press a button?
    @ Shaggy Hiker , first of all Thanks for your answer!
    1. In this program i want the user to type any numbers (double nymbers) for a, b ,c and
    2. there isn't other steps in this program., just this three number to give us one total. but as you say propably i need one button to do this. right ?

    Thanks again for your time you and other people spend for me, i appreciate that

  8. #8
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,286

    Re: A small program

    Quote Originally Posted by HyDrageN View Post
    @ Shaggy Hiker , first of all Thanks for your answer!
    1. In this program i want the user to type any numbers (double nymbers) for a, b ,c and
    2. there isn't other steps in this program., just this three number to give us one total. but as you say propably i need one button to do this. right ?

    Thanks again for your time you and other people spend for me, i appreciate that
    I would highly recommend using NumericUpDown controls instead of TextBoxes for allowing the user to type in numeric input
    Currently using VS 2015 Enterprise on Win10 Enterprise x64.

    CodeBank: All ThreadsColors ComboBoxFading & Gradient FormMoveItemListBox/MoveItemListViewMultilineListBoxMenuButtonToolStripCheckBoxStart with Windows

  9. #9
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,104

    Re: A small program

    I agree on the numeric up down, since that would restrict the entry to just numbers. You would need to be sure to set the max, min, and step properties to reasonable values.

    A button is pretty much essential. There is an alternative, but it is a pretty miserable one in practice. There are = buttons on calculators for a reason: You have to know when the user is done entering stuff. You have the same motivation. Technically, you could perform the calculations on every ValueChanged event for the controls, which would actually work fairly well, in this case, but it would mean that you would have a new value every time you changed any number in any way, and the value would be 0 until you had entered something into every box.
    My usual boring signature: Nothing

  10. #10

    Thread Starter
    Junior Member
    Join Date
    Jan 2013
    Posts
    19

    Re: A small program

    TextBox4.Text = TextBox1.Text * 0.15 + TextBox2.Text * 0.5 + TextBox3.Text * 0.3

    4 Textboxes and 1 Button was all the program.

    Can anyone tell me how to Calculate Double numbers ? when i type 5.6 6.7 8.4 the program is not calculating right.. is working only with integer numbers :/

  11. #11
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,286

    Re: A small program

    Quote Originally Posted by HyDrageN View Post
    TextBox4.Text = TextBox1.Text * 0.15 + TextBox2.Text * 0.5 + TextBox3.Text * 0.3

    4 Textboxes and 1 Button was all the program.

    Can anyone tell me how to Calculate Double numbers ? when i type 5.6 6.7 8.4 the program is not calculating right.. is working only with integer numbers :/
    NumericUpDown control
    .Minimum = Decimal.MinValue
    .Maximum = Decimal.MaxValue
    .DecimalPlaces = 1
    .InterceptArrowKeys = True

    When they click the button, simply grab the NumericUpDown's Value property and you're set.
    Currently using VS 2015 Enterprise on Win10 Enterprise x64.

    CodeBank: All ThreadsColors ComboBoxFading & Gradient FormMoveItemListBox/MoveItemListViewMultilineListBoxMenuButtonToolStripCheckBoxStart with Windows

  12. #12
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,104

    Re: A small program

    What you have should work ok, as long as certain bad conditions are met:

    1) You have Option Strict OFF.
    2) Nobody ever leaves a textbox blank, or otherwise enters something that can't be fully converted to a Double.

    Those are bad conditions, though. The NumericUpDown would remove those concerns, in which case the button click event would look like this:

    TextBox4.Text = (NumericUpDown1.Value * 0.15 + NumericUpDown2.Value * 0.5 + NumericUpDown3.Value * 0.3).ToString
    My usual boring signature: Nothing

  13. #13

    Thread Starter
    Junior Member
    Join Date
    Jan 2013
    Posts
    19

    Re: A small program

    Quote Originally Posted by Shaggy Hiker View Post
    What you have should work ok, as long as certain bad conditions are met:

    1) You have Option Strict OFF.
    2) Nobody ever leaves a textbox blank, or otherwise enters something that can't be fully converted to a Double.

    Those are bad conditions, though. The NumericUpDown would remove those concerns, in which case the button click event would look like this:

    TextBox4.Text = (NumericUpDown1.Value * 0.15 + NumericUpDown2.Value * 0.5 + NumericUpDown3.Value * 0.3).ToString
    sorry guys i started using Visual Basic 5 days now
    i don't know how it is work,
    you have right but i don't know how to do all this staff that's why i started this topic for little help from professionals

    JuggaloBrotha he wrote to me this program and thanks for his time
    Thanks to all

  14. #14
    Fanatic Member
    Join Date
    Nov 2010
    Posts
    965

    Re: A small program

    Don't be disappointed HyDragen... Start your work and search the internet resource, you will get so many things, but if not, then come over here.

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