Front Office Football Central  

Go Back   Front Office Football Central > Archives > FOFC Archive
Register FAQ Members List Calendar Mark Forums Read Statistics

Reply
 
Thread Tools
Old 09-29-2004, 10:04 AM   #1
GoldenEagle
Grizzled Veteran
 
Join Date: Dec 2002
Location: Little Rock, AR
VB Question

I have to write code that will make a program have a sales commission for a certian percentage of what the salesperson sales.

So if I had to write that if a guy sold between 100,000 and 200,000 how would I code that? Like this?

If intSales <= 100,000 && >= 200,000 Then
intSales *.75
End If

Is tthat right?
__________________
Xbox 360 Gamer Tag: GoldenEagle014

GoldenEagle is offline   Reply With Quote
Old 09-29-2004, 10:08 AM   #2
hukarez
College Starter
 
Join Date: Dec 2003
Location: Chula Vista, CA
Early in the morning for me, but maybe this?

If intSales <= 100,000 AND intSales >= 200,000 Then
intSales = intSales *.75
End If
__________________
...what we have here is a man who looks like Tarzan, but fights like Jane!
My VG collection | Xbox 360 Gamertag: ManThol | PS3 Network ID: hukarez
Doce Pares International - San Diego Council
Filipino Martial Arts Digest
tweet tweet twitter

Last edited by hukarez : 09-29-2004 at 10:08 AM.
hukarez is offline   Reply With Quote
Old 09-29-2004, 10:11 AM   #3
GoldenEagle
Grizzled Veteran
 
Join Date: Dec 2002
Location: Little Rock, AR
Is AND a key wiord in VB?
__________________
Xbox 360 Gamer Tag: GoldenEagle014
GoldenEagle is offline   Reply With Quote
Old 09-29-2004, 10:18 AM   #4
hukarez
College Starter
 
Join Date: Dec 2003
Location: Chula Vista, CA
Quote:
Originally Posted by GoldenEagle
Is AND a key wiord in VB?
Actually, it's an operator that can be used in SQL statements too.

For the most part, I think if you use the & sign, it'll append your statements into 1, as opposed as to treating them separately. For example, say you have two string variables (X and Y), with X = Hello and Y = World. If you use something like:

If X = Hello And Y = World Then
Z = X & Y
End If

...which would result in: HelloWorld.

Erg...my explanation of these things is a bit off, I know - most likely I'm getting confused (do a whole lot of VB and SQL here at work with 'And' and '&' signs in If...Then statements), but try this out:

If (intSales <= 100,000) And (intSales >= 200,000) Then
intSales = intSales *.75
End If

So if your intSales is less than or equal to 100,000, and your intSales is greater than or equal to 200,000 then your intSales will equal the present amount it is, multiplied by .75 and what not. Hmm...wait a minute.

Try:

If (intSales >= 100,000) And (intSales <= 200,000) Then
intSales = intSales * .75
End If

Essentially, the 'And' operator here will run through if both instances are true.
In this case, if your intsales is greater than or equal to 100,000 *and* is also less than or equal to 200,000 then your intSales will equal your present amount times .75 and what not. Otherwise, it'll fall out of the statement.
__________________
...what we have here is a man who looks like Tarzan, but fights like Jane!
My VG collection | Xbox 360 Gamertag: ManThol | PS3 Network ID: hukarez
Doce Pares International - San Diego Council
Filipino Martial Arts Digest
tweet tweet twitter

Last edited by hukarez : 09-29-2004 at 10:27 AM.
hukarez is offline   Reply With Quote
Old 09-29-2004, 01:23 PM   #5
Mr. Wednesday
Pro Starter
 
Join Date: Jul 2003
Location: South Bend, IN
'&' is the string concatenation operator in VB
'&&' is the logical and operator in C, C++, and Java (possibly others as well)
And is the bitwise and operator
Or is the bitwise or operator
VB classic does not have logical operators, all of the boolean logic is handled bitwise (with True being all bits on and False being all bits off, VB does not adhere to the [IMO unfortunate] C legacy of True as one bit on).

Also, I don't think the comma will work. I think you'll have to enter the numbers without it.

Finally, I doubt this:
intSales = intSales * 0.75
is what you want.

Maybe something like this instead:
dblComm = intSales * 0.75
(if fractional cents are important to you, beware the inexactness of FP math and consider using scaled integers instead)
__________________
Hattrick - Brays Bayou FC (70854) / USA III.4
Hockey Arena - Houston Aeros / USA II.1

Thanks to my FOFC Hattrick supporters - Blackout, Brillig, kingfc22, RPI-fan, Rich1033, antbacker, One_to7, ur_land, KevinNU7, and TonyR (PM me if you support me and I've missed you)

Last edited by Mr. Wednesday : 09-29-2004 at 01:24 PM.
Mr. Wednesday is offline   Reply With Quote
Old 09-29-2004, 01:32 PM   #6
hukarez
College Starter
 
Join Date: Dec 2003
Location: Chula Vista, CA
Quote:
Originally Posted by Mr. Wednesday
Finally, I doubt this:
intSales = intSales * 0.75
is what you want.

Maybe something like this instead:
dblComm = intSales * 0.75
(if fractional cents are important to you, beware the inexactness of FP math and consider using scaled integers instead)

Well, unless he's using another variable for the end result of the If...Then statement. dblComm, or X, or something else. I'm assuming he's retaining the same intSales variable for a finalized result. The commas probably won't work - thanks for bringing that to light. 100000 and 200000 being the alternative, I'm wondering how the input for the initial intSales values are being handled, if they're including commas or not?
__________________
...what we have here is a man who looks like Tarzan, but fights like Jane!
My VG collection | Xbox 360 Gamertag: ManThol | PS3 Network ID: hukarez
Doce Pares International - San Diego Council
Filipino Martial Arts Digest
tweet tweet twitter
hukarez is offline   Reply With Quote
Old 09-29-2004, 01:38 PM   #7
Mr. Wednesday
Pro Starter
 
Join Date: Jul 2003
Location: South Bend, IN
He should be using a different variable for the result, among other things the result will not necessarily be an integer. If the commission is supposed to be in even dollars, then I guess it would work, but the code would be misleading (intSales would only actually represent sales up until the point where you calculate the commission).

Dunno about input, if it's done right I think VB will translate correctly from text to a numeric variable with the commas.
__________________
Hattrick - Brays Bayou FC (70854) / USA III.4
Hockey Arena - Houston Aeros / USA II.1

Thanks to my FOFC Hattrick supporters - Blackout, Brillig, kingfc22, RPI-fan, Rich1033, antbacker, One_to7, ur_land, KevinNU7, and TonyR (PM me if you support me and I've missed you)
Mr. Wednesday is offline   Reply With Quote
Old 09-29-2004, 01:45 PM   #8
hukarez
College Starter
 
Join Date: Dec 2003
Location: Chula Vista, CA
The wonders of object oriented programming. Well, to an extent with VB I suppose.

Well, it's not much information to really ride on. Perhaps it's just a minor sub-routine by which another event calls forth the results? Speculation here at this point. I'm assuming things are going well regardless.

I am curious about the end result though. So GoldenEagle, if you've managed to succeed, care to share what you came up with that worked? More so to satiate curiousity on my part really.
__________________
...what we have here is a man who looks like Tarzan, but fights like Jane!
My VG collection | Xbox 360 Gamertag: ManThol | PS3 Network ID: hukarez
Doce Pares International - San Diego Council
Filipino Martial Arts Digest
tweet tweet twitter
hukarez is offline   Reply With Quote
Old 09-29-2004, 01:50 PM   #9
Joe
Pro Starter
 
Join Date: Jun 2004
Location: Minneapolis
this thread makes my head hurt
Joe is offline   Reply With Quote
Old 09-29-2004, 02:22 PM   #10
Daimyo
College Starter
 
Join Date: Oct 2000
Location: Berkeley
I've been using vbscript a lot more than real vb lately, but I think you'd want something like (assuming that since you don't care about cents for the sales that you also don't care about cents for the commision):

Code:
function getCommision (iSales as integer) as integer if (iSales >= 100000) AND (iSales <= 200000) then getCommision = cInt (0.75 * iSales) else '... other code goes here ... end if end function

Last edited by Daimyo : 09-29-2004 at 02:26 PM.
Daimyo is offline   Reply With Quote
Old 09-29-2004, 03:07 PM   #11
Mr. Wednesday
Pro Starter
 
Join Date: Jul 2003
Location: South Bend, IN
Quote:
Originally Posted by hukarez
The wonders of object oriented programming. Well, to an extent with VB I suppose.
I don't see that OO has anything to do with this example, which is purely procedural.

__________________
Hattrick - Brays Bayou FC (70854) / USA III.4
Hockey Arena - Houston Aeros / USA II.1

Thanks to my FOFC Hattrick supporters - Blackout, Brillig, kingfc22, RPI-fan, Rich1033, antbacker, One_to7, ur_land, KevinNU7, and TonyR (PM me if you support me and I've missed you)
Mr. Wednesday is offline   Reply With Quote
Old 09-29-2004, 03:10 PM   #12
John Galt
Pro Starter
 
Join Date: Oct 2000
Location: The Internets
2/3?
__________________
I do mind, the Dude minds. This will not stand, ya know, this aggression will not stand, man. - The Dude
John Galt is offline   Reply With Quote
Old 09-29-2004, 04:25 PM   #13
hukarez
College Starter
 
Join Date: Dec 2003
Location: Chula Vista, CA
Quote:
Originally Posted by Mr. Wednesday
I don't see that OO has anything to do with this example, which is purely procedural.

It was a joke.

EDIT: Apparently, a bad one!
__________________
...what we have here is a man who looks like Tarzan, but fights like Jane!
My VG collection | Xbox 360 Gamertag: ManThol | PS3 Network ID: hukarez
Doce Pares International - San Diego Council
Filipino Martial Arts Digest
tweet tweet twitter

Last edited by hukarez : 09-29-2004 at 04:26 PM.
hukarez is offline   Reply With Quote
Old 09-29-2004, 05:15 PM   #14
The Afoci
Pro Rookie
 
Join Date: Jan 2003
Location: Moorhead
Quote:
Originally Posted by John Galt
2/3 my way to Fargo

Time to grease the goat.
__________________
I had something.
The Afoci is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is On
Forum Jump


All times are GMT -5. The time now is 11:46 AM.



Powered by vBulletin Version 3.6.0
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.