473,725 Members | 2,127 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Creating a Shipping Charge Calculator

26 New Member
Hello everybody. I am a complete noob in writing VB code. I don't have a problem drawing a form, but when it comes to code. I am lost.
I have a user interface design class and we have a small project due. I was wondering if anyone could give me some mega help.
The project we have to complete is the following:

The Fast Freight Shipping Company charges the rates listed in the following table:

Weight of the Package (in kilograms) / Shipping rate per Mile
2kg or less / $0.01
over 2kg, but not more than 6kg /$0.015
over 6kg, but not more than 10kg /$0.02
over 10kg, but not more than 20kg / $0.025

Create an application that allows the user to enter the weight of the package and the distance it is to be shipped, and then displays the charges.

Input validation: Do not accept values of 0 or less for the weight of the package. Do not accept weights of more thann 20 kg(this is the maximum weight the company will ship) Do not accept distances of less than 10 miles or more than 3000 miles. These are the company's minimum and maximum shipping distances. Use exception handling to check for non-numeric data.



I'm knd of asking for someone to pretty much write the code I would need to make this function properly. I will be trying to mess around with it while I wait for any response. Thanks very much in advancne
Mar 27 '07 #1
19 9736
Dököll
2,364 Recognized Expert Top Contributor
Ahhh, the good old days :-) Hello rents!

I have had similar projects in the past..I am sure likewise for members here. Would you be able to post what you have thus far so one can take a look?

It'd be helpful to you and to this forum if in need of a quick response...

When is this due?

Dököll
Mar 28 '07 #2
rents
26 New Member
Dokoll,

Thanks for the response. So far, I have only created the form itself. With buttons and labels and what not. The only code I have entered is for the exit button to work :)

I'm not exactly sure what you like to me show on here, so I just copied and pasted the part where the code is placed.

Private Sub Label1_Click(By Val sender As System.Object, ByVal e As System.EventArg s) Handles Label1.Click

End Sub

Private Sub Label2_Click(By Val sender As System.Object, ByVal e As System.EventArg s) Handles Label2.Click

End Sub

Private Sub Label3_Click(By Val sender As System.Object, ByVal e As System.EventArg s) Handles Label3.Click

End Sub

Private Sub btnClear_Click( ByVal sender As System.Object, ByVal e As System.EventArg s) Handles btnClear.Click

End Sub

Private Sub btnExit_Click(B yVal sender As System.Object, ByVal e As System.EventArg s) Handles btnExit.Click
'Exit Calculator

Me.Close()

End Sub

Private Sub txtWeight_TextC hanged(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles txtWeight.TextC hanged

End Sub

Private Sub txtDistance_Tex tChanged(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles txtDistance.Tex tChanged

End Sub

Private Sub lblCost_TextCha nged(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles lblCost.TextCha nged

End Sub

Private Sub btnCalculate_Cl ick(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles btnCalculate.Cl ick

End Sub
End Class

i guess this would give you an idea as to what I have on the form. I feel a little silly not knowing even where to begin to write code. I mean I know where it goes, but just confused as to what to type in first.

If you need more info from me, please let me know. This project is due on Saturday, but I'd like to have it finished by at least Friday.
Thanks
Mar 28 '07 #3
Dököll
2,364 Recognized Expert Top Contributor
OK, Rents...Thanks for your prompt response. I have a simple code you can add to the mix. Let me fetch it and will post. If this does not work, I'll let someone else take a stab at it. In a bit!
Mar 28 '07 #4
Dököll
2,364 Recognized Expert Top Contributor
Also, perhaps you can reduce your button clicks to at least a couple! I just noticed you have buttons for almost every event. Is this necessary? It's likely the project at hand wants you to submit in this fashion and that's ok, if this is a fact, please ignore my comment here.

To begin, and assuming this is what you hope to achieve:

(1) you will need to dimension a place holder for your dollar amounts as currency (i.e. Textbox that will carry $0.00...)
(2) you will also need to dimension a place holder as integer (i.e. Textbox that should carry kg units and so on...

Please stay tuned while I fetch for code.
Mar 28 '07 #5
Dököll
2,364 Recognized Expert Top Contributor
rents, my friend, I do not have good news, but no worries. My small program is almost 5 years old, hadn't touch it since graduation. Anyway, the code is not working properly. I could not find you a good tutorial on this, so I will attempt to help you from memory:

(1) Looks like you will need to tell the program to look for instances where a certain textbox/label has greater or equal to 10 miles (a select case or if statement should help you deal with this).

(2) You will also need to tell VB you want not more but less than 3000 miles, you can add this in the same select or if statement, or a loop of some sort

(3) VB must know you will not accept more than 20kg, add to your statements as well

(4) As mentioned before, you will need to dimension the currency textbox/label as currency so VB know amounts will be added.

Here is part of my old code that works:

Expand|Select|Wrap|Line Numbers
  1.  
  2.     Dim num_one As Currency ''Specific to a textbox called Price.Text
  3.     Dim num_two As Integer    'Specific to a textbox called Items.Text
  4.     Dim Total_results_num As Currency ''Specific to a label called Total_results
  5.  
  6.     num_one = Int(Price.Text)
  7.     num_two = Int(Items.Text)
  8.  
  9.     Total_results_num = num_one + num_two 'calculates amount with items
  10.     Total_results = Total_results_num
  11.  
  12.  
Give this one a whirl, see what pops up.

Good luck!
Mar 28 '07 #6
Dököll
2,364 Recognized Expert Top Contributor
Whoops! I found out the problem, it works now. Since it is a label, I must add .Caption to it, thus:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub Total_Click()                        'total button calculator
  3.  
  4.     Dim num_one As Currency                 'see textbox named Price.Text
  5.     Dim num_two As Integer                    'see textbox named Price.Text
  6.     Dim Total_results_num As Currency   'see label named Total_results.Caption
  7.  
  8.     num_one = Int(Price.Text)
  9.     num_two = Int(Items.Text)
  10.     Total_results_num = num_one + num_two
  11.     Total_results.Caption = Total_results_num
  12.  
  13.  
  14. End Sub  
  15.  
  16.  
There, try this. You'll have to do most of the work, Hopefuly this gets you started right :-)
Mar 28 '07 #7
rents
26 New Member
Dokoll

Thanks for all the responses, but I still do not understand what is going on.
Like what exact code should I put in where?
Mar 28 '07 #8
rents
26 New Member
Private Sub Total_Click() 'total button calculator

Dim num_one As Currency 'see textbox named Price.Text
Dim num_two As Integer 'see textbox named Price.Text
Dim Total_results_n um As Currency

ok..for this part..where it says Dim num_one As Currency..

what should I put in for mine..for my weight textbox (txtweight)

Dim decWeight As ???? (it's supposed to run in kg)
Mar 28 '07 #9
rents
26 New Member
ok, I've kind of figured out what I am doing. But now I've run into a problem.
I have these IF statements in my calculate button


If IsNumeric(txtWe ight.Text) = False Then
lblErrorMessage .Text = "Weight must numeric"
lblErrorMessage .Visible = True
Return
End If

If IsNumeric(txtDi stance.Text) = False Then
lblErrorMessage .Text = "Distance must be numeric"
lblErrorMessage .Visible = True
Return
End If

but when I test the Distance with some letter, the error label tells me "Weight must be numeric"

What am I doing wrong?
Mar 29 '07 #10

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

Similar topics

0
1201
by: Brian Huether | last post by:
I know there are lots of shopping carts out there (ZenCart, etc). But so far none of them seem to have a good built in shipping calculator with various options. Can anyone recommend something? And what do people think of products like this: http://shop.finalhost.com/dreamweaver-plus.asp The bottom one seems great. Other than not being able to handle UPS shipping, has tons of useful features. But maybe there is more than meets the eye.
1
2301
by: Jason Burr | last post by:
Has anybody used the UPS tools for calculating shipping and if so how did they go about it? I have seen the articles on 4guysfromrolla but that appears to be using xml component to get the data from the ups site rather than using the developers tools provided by UPS. I am just not sure the best way to go about this. Anybody with experience using this who could give me some pointers would be greatly appreciated. On their site if you dont...
1
1254
by: Tim | last post by:
Anyone know of any good shipping components for adding to a custom built shopping cart. Or if you develop a shipping piece, is it best to ship by weight or by item meaning that each item will cost X amount to ship. Thanks
0
1095
by: McKirahan | last post by:
I am developing a shopping cart application and would like to determine (based on weight, dimensions, and destination) the actual shipping charges that USPS, UPS, FedEx, DHL, and/or Airborne would charge. Each shipper has APIs that support this functionality... E-Commerce Shipping Solutions http://www.nfib.com/object/1583793.html Does anyone have or know of any information about doing this.
10
3353
by: collegestudent | last post by:
hello there, I was wondering if anyone could give me some advice on where to start on a project for college where I have to design and create a hand-held calculator simulation in Visual Basic.Thankyou!
6
4626
by: Chris Buckett | last post by:
Hi, I was just wondering if anyone has had any experience in developing a shipping matrix. We are based in the UK, and we need to ship both locally and internationally. Local shipping is priced by weight and doesn't matter about the number of packages, international shipping is by weight and package size, so we need to know the number of packages.
4
7820
by: tudyfruity18 | last post by:
I'm suppose to write an applet that contains two buttons Investment calculator and Loan Calculator. When the Investment Calculator button is clicked, a frame appears in a new window for calculating future investment values. When you click Loan Calculator button, a frame appears in a separate new window for computong loan payments. Here's my coding: // Lab3.java: import java.awt.*; import java.awt.event.*; import javax.swing.*; ...
4
9706
by: aprillynn82 | last post by:
I can not seem to get the code correct to calculate shipping charges based on weight and distance. The info is: Weight of the Package (in kilograms) / Shipping rate per Mile 2kg or less / $0.01 over 2kg, but not more than 6kg /$0.015 over 6kg, but not more than 10kg /$0.02 over 10kg, but not more than 20kg / $0.025 Input validation: Do not accept values of 0 or less for the weight of the package. Do not accept weights of more thann 20...
1
4247
AaronL
by: AaronL | last post by:
Hello, First I would like to say thank you all for your help in the past. I am stumped again. I am creating an e-commerce system and I want to be able to upload images to the server and assign them to products. For the product ID, I have an auto increment value for the primary key to avoid duplicate item numbers. Since I do not want to pass all of my record values to my image upload program (when I write it), I assume to just submit...
0
8888
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9257
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9176
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9113
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8097
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6702
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6011
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4519
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3221
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.