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
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
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
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!
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.
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: -
-
Dim num_one As Currency ''Specific to a textbox called Price.Text
-
Dim num_two As Integer 'Specific to a textbox called Items.Text
-
Dim Total_results_num As Currency ''Specific to a label called Total_results
-
-
num_one = Int(Price.Text)
-
num_two = Int(Items.Text)
-
-
Total_results_num = num_one + num_two 'calculates amount with items
-
Total_results = Total_results_num
-
-
Give this one a whirl, see what pops up.
Good luck!
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: -
-
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_num As Currency 'see label named Total_results.Caption
-
-
num_one = Int(Price.Text)
-
num_two = Int(Items.Text)
-
Total_results_num = num_one + num_two
-
Total_results.Caption = Total_results_num
-
-
-
End Sub
-
-
There, try this. You'll have to do most of the work, Hopefuly this gets you started right :-)
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?
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)
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?
Sign in to post your reply or Sign up for a free account.
Similar topics |
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.
|
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...
|
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
|
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.
|
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!
| |
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.
|
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.*;
...
|
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...
|
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...
|
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...
|
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...
| |
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,...
|
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...
|
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...
|
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...
|
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();...
|
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...
| |
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
| |