473,396 Members | 1,871 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

VB Newbie!

I am new to VB and have to make a commission calculator, but I am running into problems.

I have four text boxes where the following information will be added by the viewer:

- The Stock Broker's Name
- The Stock Name
- The Price Per Share
- The Number of Shares

I then have to multiply the number of shares by the price of the shares and output it in a message box. This part I have been able to do.

The problem I have not been able to accomplish is outputing the broker's and stock's names in the same message box as well as make a conditional statement to be placed underneath the total commission.

If the price of shares is less than or equal to $50 then I have to tell them their commission rate is 19% If the price is greater than $50 then the rate is 26%. And lastly, if the number of shares is below 150 then multiply 1.5 times rate.

I believe that I need nested IfElse statements to do the first conditional section and an AndAlso statement for the shares condition. i just don't know how to write the syntax correctly.

Help!!!
Nov 4 '06 #1
4 1588
willakawill
1,646 1GB
I am new to VB and have to make a commission calculator, but I am running into problems.

I have four text boxes where the following information will be added by the viewer:

- The Stock Broker's Name
- The Stock Name
- The Price Per Share
- The Number of Shares

I then have to multiply the number of shares by the price of the shares and output it in a message box. This part I have been able to do.

The problem I have not been able to accomplish is outputing the broker's and stock's names in the same message box as well as make a conditional statement to be placed underneath the total commission.

If the price of shares is less than or equal to $50 then I have to tell them their commission rate is 19% If the price is greater than $50 then the rate is 26%. And lastly, if the number of shares is below 150 then multiply 1.5 times rate.

I believe that I need nested IfElse statements to do the first conditional section and an AndAlso statement for the shares condition. i just don't know how to write the syntax correctly.

Help!!!
Hi, if you would be so kind as to post the code you already have we will be in a better position to assist you.

Thanks
Nov 4 '06 #2
Killer42
8,435 Expert 8TB
I am new to VB and have to make a commission calculator, but I am running into problems.

I have four text boxes where the following information will be added by the viewer:

- The Stock Broker's Name
- The Stock Name
- The Price Per Share
- The Number of Shares

I then have to multiply the number of shares by the price of the shares and output it in a message box. This part I have been able to do.

The problem I have not been able to accomplish is outputing the broker's and stock's names in the same message box as well as make a conditional statement to be placed underneath the total commission.

If the price of shares is less than or equal to $50 then I have to tell them their commission rate is 19% If the price is greater than $50 then the rate is 26%. And lastly, if the number of shares is below 150 then multiply 1.5 times rate.

I believe that I need nested IfElse statements to do the first conditional section and an AndAlso statement for the shares condition. i just don't know how to write the syntax correctly.

Help!!!
Assuming you have the various pieces of information in appropriate variables already, you could build a string to display, something like this
Expand|Select|Wrap|Line Numbers
  1. Dim Msg As String
  2. Msg = "Price: " & Format(Price) & vbNewLine _
  3.   & "Shares: " & Format(Shares) & vbNewLine _
  4.   & "Total: " & Format(Total) & vbNewLine _
  5.   & "Broker: " & BrokerName & vbNewLine _
  6.   & "Stock: " & Stockname & vbNewLine
  7.  
  8. If Price <= 50 Then
  9.   Commission = 0.19
  10. Else
  11.   Commission = 0.26
  12. End If
  13. If Shares < 150 Then
  14.   Commission = Commission * 1.5
  15. End If
  16. Msg = Msg & "Commission: " & Format(Commission, "%")
  17. MsgBox Msg
This is just off the top of my head, and not tested. But it should help to get you going. Also, I couldn't remember the right way to format the percentage. Check out the Format() function in online help for details.
Nov 5 '06 #3
Also, I couldn't remember the right way to format the percentage. Check out the Format() function in online help for details.
I am pretty sure it is

Expand|Select|Wrap|Line Numbers
  1. FormatPercent()
Nov 6 '06 #4
Killer42
8,435 Expert 8TB
I am pretty sure it is
Expand|Select|Wrap|Line Numbers
  1. FormatPercent()
Neat! Thanks for that, I hadn't actually encountered FormatPercent, or didn't remember it. I normally just use Format() with various formatting strings.
Nov 6 '06 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Philippe C. Martin | last post by:
Hi, Is there a program out there that would generate the C code to instantiate objects and call them: ex: miracle.exe -i mymodule.py -o module_internface.c ? I seem to recall a _yes_ to...
0
by: Twayne | last post by:
Twayne wrote: That's the verification I was looking for I think. There are times that doesn't seem to be so, but perhaps I'll looking at the wrong side of the tree in the wrong forest ... I...
5
by: Banibrata Dutta | last post by:
Hi, I've gone through the list of "language differences" between 2.3 / 2.4 & 2.5 of CPython. I've spend around 2 weeks now, learning v2.5 of CPython, and I consider myself still very very...
16
by: Raxit | last post by:
Hi, i was reading/learning some hello world program in python. I think its very simillar to Java/C++/C#. What's different (except syntax) ? what can i do easily with python which is not easy...
10
by: Peter Michaux | last post by:
On May 14, 8:55 pm, Prisoner at War <prisoner_at_...@yahoo.comwrote: Get it from the library. I cannot imagine needing to own an HTML book. There are plenty of good references on the web....
2
by: r_ahimsa_m | last post by:
Could you recommend me some free JavaScript validator? I was using JSlint but it reports nonsense errors. Please help. Thanks. /RAM/
6
by: raylopez99 | last post by:
Will ASP.NET 3.0 work under Visual Studio 2005? And what is a good newbie ASP.NET book? Subject: Will ASP.NET 3.0 work under Visual Studio 2005? And what is a good newbie ASP.NET book? My...
3
Lokean
by: Lokean | last post by:
Sorry for this newbie question, this is not my realm of expertese. I have searched google, tried several applications that claim they can do this, such as Mapforce, which I found confusing, to...
5
by: Dave | last post by:
I am new to Visual Web Developer 2005 Expres. I am using absolute positioning and every time I add a button control to my web form its width extends all the way to the edge of the page. IOW I...
5
by: SharkD | last post by:
Hi! I'm a total newbie when it comes to ASP (or any type of server-side programming). I want to start a project that does the following: 1. query Wikipedia for information regarding...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.