A Visual Basic 2005 querry

Zap Brannigan

Golden Member
Oct 14, 2004
1,887
0
0
I'm having trouble coding something here.

I need to code the calculate buttons click event procedure and to use variables.

Then to use the To String method to display a thousands separator if needed and two decimal places in the total sales and commission amounts.

the XCalcButton Click event procedure

1. calculate total sales = New York Sales + Maine Sales + Florida Sales

2. calculate the commission - total sales *5%

3. display total sales and commision in the xTotalSalesLabel controls

4. Send the focus to the New York Text Box


Any help would be much appreciated!
 

CycloWizard

Lifer
Sep 10, 2001
12,348
1
81
Do you have any code yet? I haven't used VB2005 (went straight from v6 to 2008 after a decade of not using it for anything), but put up what you have and I can probably point you in the right direction.
 

polarbear6

Golden Member
Jul 14, 2008
1,161
1
0
well i dont remember the code that much but i can give u hints on what to do
you can always use snippets to accomplish what i say

first
dim nwysales, maine, florida as integer
dim total as integer= nwysales+ maine + florida
total = total / 1000 (this will give a decimal place near the thousand mark which we can find out by instr method and replace with a coma)
label.text = total
dim commision as intger = total * 0.05
newyorktextbox.getfocus(i dont remember the code that much)

 

PhatoseAlpha

Platinum Member
Apr 10, 2005
2,131
21
81
The relevant methods are

Control.focus()
Double.toString()
Double.isNaN()
String.format()


I expect code will look like this:

Dim Total, Commission, Buffer as double
Total = 0
Buffer = val(txtNY.text)
if (not buffer.isNan())
Total += buffer
end if
Buffer = val(txtMaine.text)
if (not buffer.isNan())
Total += buffer
end ifBuffer = val(txtFlorida.text)
if (not buffer.isNan())
Total += buffer
end if
Commission = Total * .05
lblCommission.text = commission.tostring.format("{0:c}")
lblTotal.text = Total.tostring.format("{0:c}")
txtNewYork.focus()









 

Zap Brannigan

Golden Member
Oct 14, 2004
1,887
0
0
Originally posted by: ganesh1
well i dont remember the code that much but i can give u hints on what to do
you can always use snippets to accomplish what i say

first
dim nwysales, maine, florida as integer
dim total as integer= nwysales+ maine + florida
total = total / 1000 (this will give a decimal place near the thousand mark which we can find out by instr method and replace with a coma)
label.text = total
dim commision as intger = total * 0.05
newyorktextbox.getfocus(i dont remember the code that much)

Hi Thanks!

I'm messing around with this now but I forgot ot mention that that I had to start the code with,

Option Explicit On
Option Strict On

This is giving me some troubles in the conversions, as you can probably guess I'm a rookie at this. lol
 

Zap Brannigan

Golden Member
Oct 14, 2004
1,887
0
0
Originally posted by: CycloWizard
Do you have any code yet? I haven't used VB2005 (went straight from v6 to 2008 after a decade of not using it for anything), but put up what you have and I can probably point you in the right direction.

Here's what I have so far,



Option Explicit On
Option Strict On

Public Class MainForm

Private Sub xExitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles xExitButton.Click
Me.Close()

End Sub

Private Sub xCalcButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles xCalcButton.Click


Dim nysales As Integer
Dim mainesales As Integer
Dim floridasales As Integer

Dim total As Integer = nysales + mainesales + floridasales
 

brandonbull

Diamond Member
May 3, 2005
6,362
1,219
126
public class foo_Main
const CommissionRate as double = .05

private sub foo_click()

foo()

end sub

private sub foo()
dim dblNewYorkSales, dblMaineSales, dblFloridaSales, dblTotalSales, dblCommission as double
try

if isnumeric(txtnewyork.text) then
dblNewYorkSales = txtnewyork.text
end if

if isnumeric(txtmaine.text) then
dblMaineSales= txtmaine.text
end if

if isnumeric(txtflorida.text) then
dblFloridaSales= txtflorida.text
end if


dblTotalSales = dblNewYorkSales + dblMaineSales + dblFloridaSales
dblCommission = dblTotalSales * CommissionRate

lblTotalSales.text = FormatCurrency(dblTotalSales , 2)
lblCommission.text = FormatCurrency(dblCommission, 2)

txtnewyork.focus()

catch ex as exception

end try
end sub
end class



May be a little too verbose but you should get the idea
 

Zap Brannigan

Golden Member
Oct 14, 2004
1,887
0
0
Hmmmm, I'll try to poke around with it again tomorrow.

Thanks for the help! Anything else added would be appreciated too.

Much to read I still have......lol
 
sale-70-410-exam    | Exam-200-125-pdf    | we-sale-70-410-exam    | hot-sale-70-410-exam    | Latest-exam-700-603-Dumps    | Dumps-98-363-exams-date    | Certs-200-125-date    | Dumps-300-075-exams-date    | hot-sale-book-C8010-726-book    | Hot-Sale-200-310-Exam    | Exam-Description-200-310-dumps?    | hot-sale-book-200-125-book    | Latest-Updated-300-209-Exam    | Dumps-210-260-exams-date    | Download-200-125-Exam-PDF    | Exam-Description-300-101-dumps    | Certs-300-101-date    | Hot-Sale-300-075-Exam    | Latest-exam-200-125-Dumps    | Exam-Description-200-125-dumps    | Latest-Updated-300-075-Exam    | hot-sale-book-210-260-book    | Dumps-200-901-exams-date    | Certs-200-901-date    | Latest-exam-1Z0-062-Dumps    | Hot-Sale-1Z0-062-Exam    | Certs-CSSLP-date    | 100%-Pass-70-383-Exams    | Latest-JN0-360-real-exam-questions    | 100%-Pass-4A0-100-Real-Exam-Questions    | Dumps-300-135-exams-date    | Passed-200-105-Tech-Exams    | Latest-Updated-200-310-Exam    | Download-300-070-Exam-PDF    | Hot-Sale-JN0-360-Exam    | 100%-Pass-JN0-360-Exams    | 100%-Pass-JN0-360-Real-Exam-Questions    | Dumps-JN0-360-exams-date    | Exam-Description-1Z0-876-dumps    | Latest-exam-1Z0-876-Dumps    | Dumps-HPE0-Y53-exams-date    | 2017-Latest-HPE0-Y53-Exam    | 100%-Pass-HPE0-Y53-Real-Exam-Questions    | Pass-4A0-100-Exam    | Latest-4A0-100-Questions    | Dumps-98-365-exams-date    | 2017-Latest-98-365-Exam    | 100%-Pass-VCS-254-Exams    | 2017-Latest-VCS-273-Exam    | Dumps-200-355-exams-date    | 2017-Latest-300-320-Exam    | Pass-300-101-Exam    | 100%-Pass-300-115-Exams    |
http://www.portvapes.co.uk/    | http://www.portvapes.co.uk/    |