September 19, 2020, 12:40:57 pm
News: If someone gives you assistance give them a Good Star
Pages: [1] 2   Go Down
Author Topic: simple addition help  (Read 2190 times)
Naomi
Newbie
*

Stars: +0/-0
Offline Offline

Posts: 23


WWW
« on: January 28, 2003, 02:32:49 am »

this is really stupid but when i do this:
[vbcode]frmMain.Text92.Text = frmMain.Text85.Text + frmMain.Text87.Text + frmMain.Text89.Text + frmMain.Text91.Text[/vbcode]

the result displays in the text92 like this:

500 200 650 800

why wont it add?
Logged

Joe
Supporters
*

Stars: +0/-0
Offline Offline

Posts: 6104



WWW
« Reply #1 on: January 28, 2003, 02:48:28 am »

That is because the + operator acts the same as & in regard to Strings.  Try
[vbcode]
    frmMain.Text92.Text = Val(frmMain.Text85.Text) + Val(frmMain.Text87.Text) + _
                          Val(frmMain.Text89.Text) + Val(frmMain.Text91.Text)
[/vbcode]
Logged

Let the probing begin! smile

Naomi
Newbie
*

Stars: +0/-0
Offline Offline

Posts: 23


WWW
« Reply #2 on: January 28, 2003, 03:09:51 am »

Thank you smile
Logged

Joe
Supporters
*

Stars: +0/-0
Offline Offline

Posts: 6104



WWW
« Reply #3 on: January 28, 2003, 03:19:08 am »

What is the exact format of the data in the textboxes?  Is it like $50.00, as opposed to 50.00?
Logged

Let the probing begin! smile

Naomi
Newbie
*

Stars: +0/-0
Offline Offline

Posts: 23


WWW
« Reply #4 on: January 28, 2003, 03:21:51 am »

problem fixed Wink

i had this:
[vbcode]Text85.Text = Format$(Text85.Text, \"currency\")[/vbcode]
in the textbox change event, was causing it not to work

Thanks again
Logged

Bruce Fox
Old Timer
*

Stars: +0/-0
Offline Offline

Posts: 2307



WWW
« Reply #5 on: January 28, 2003, 11:58:41 am »

Naomi,

It\'s also good practice to try and give your Objetcs (TextBoxes, Labels etc) usefull names (with Hungarian Notation - txt for TextBox).
It may help latter when debugging, or more importantly, help
someone else looking over your code.

ie. Text82.Text may be \'Unit Price\' re-written as TtxtUnitPrice.Text
Text85.Text may be \'Total Cost\' re-written as txtTotalCost.Text, like:
[vbcode]
    txtUnitPrice.Text = .....

    txtExtendPrice.Text = .....

    txtTotalCost.Text = .....
[/vbcode]



Bruce.
Logged


One of the best bands of all time:

Naomi
Newbie
*

Stars: +0/-0
Offline Offline

Posts: 23


WWW
« Reply #6 on: January 28, 2003, 07:45:16 pm »

Quote
It\'s also good practice to try and give your Objetcs (TextBoxes, Labels etc) usefull names (with Hungarian Notation - txt for TextBox).
But im not Hungarian.

Just kidding, that,s good advice.

Thanks Guys
beerchug
Logged

rjlohan
Founders
*

Stars: +0/-0
Offline Offline

Posts: 2355



WWW
« Reply #7 on: February 07, 2003, 07:24:48 am »

\'Hungarian\' notation? Where\'d you get that from Bruce? Another Tounge
I can\'t say I\'ve ever heard that before. smile
Logged

---------------------------------------
-RJ Lohan
Ryan.J.Lohan@student.uts.edu.au
---------------------------------------
"Second?!? That's just a fancy word for 'loser'!!"
---------------------------------------

Joe
Supporters
*

Stars: +0/-0
Offline Offline

Posts: 6104



WWW
« Reply #8 on: February 07, 2003, 12:43:47 pm »

Yeah, I didn\'t even know Hungarios had computers

dunno
Logged

Let the probing begin! smile

Pc_Madness
Ancient Poster
*

Stars: +0/-0
Offline Offline

Posts: 5349



WWW
« Reply #9 on: February 07, 2003, 12:56:19 pm »

I didn\'t even know I had a computer... :confused:
Logged


jim mcnamara
Sr. Member
*

Stars: +0/-0
Offline Offline

Posts: 277


WWW
« Reply #10 on: February 07, 2003, 03:11:18 pm »

C\'mon you guys.

Hungatrian notation has been around for a long time.  Started with programmers coding Windows and unix.

The idea is simple - look at any variable and you know it\'s datatype.  All of our production code uses that same standard, plus we compile our C code with full ANSI compliance.

The only exception is we expect single character control variable names for  loops. This kind of thing.....

Code:

 for(i=0;i[10;i++) { do stuff; }

Logged

Bruce Fox
Old Timer
*

Stars: +0/-0
Offline Offline

Posts: 2307



WWW
« Reply #11 on: February 09, 2003, 10:13:46 pm »

Quote
Originally posted by rjlohan
\'Hungarian\' notation? Where\'d you get that from Bruce? Tongue
I can\'t say I\'ve ever heard that before. smile

I use it all the time. lst for ListBox, cbo for ComboBox etc.

I have seen it used ofen. I have Hungarian Notation lists in a few reference
books.

Personaly, I find it so much easier reading and writting my code.

It helps reduce errors (like using \'Option Explicit\') when writting
code. Eg. If the control you want to code is a TextBox, then in the IDE
its name best start with txt. Additionaly, reduces confussion against Labels and TexBoxes of the same name.
(lblAmount, txtAmount)

RJ, I\'m supprised none of the UNI lecturers have mentioned it :confused:




Bruce.
Logged


One of the best bands of all time:

rjlohan
Founders
*

Stars: +0/-0
Offline Offline

Posts: 2355



WWW
« Reply #12 on: February 09, 2003, 10:26:53 pm »

I think my question was missed. I use this notation with prejudice, but I never heard it called \'Hungarian\' notation before... dunno  Another Tounge
Logged

---------------------------------------
-RJ Lohan
Ryan.J.Lohan@student.uts.edu.au
---------------------------------------
"Second?!? That's just a fancy word for 'loser'!!"
---------------------------------------

James Stanich
Ancient Poster
*

Stars: +0/-0
Offline Offline

Posts: 6091



WWW
« Reply #13 on: February 10, 2003, 03:59:15 am »

Quote
Originally posted by rjlohan
I think my question was missed. I use this notation with prejudice, but I never heard it called \'Hungarian\' notation before... dunno  Another Tounge

A little detail :
Logged

If my or help you, PLEASE INDICATE BY SELECTING THE BUTTON BELOW)  :Rock:

Check out the new API resource :

If you are visiting from that OTHER site, Why not take the time to register with us

Martin Wallace
Founders
*

Stars: +1/-0
Offline Offline

Posts: 3602


God is dead, I have surpassed him.


WWW
« Reply #14 on: February 10, 2003, 09:32:40 am »

Another couple of articles with details:




Although, RJ, you best not get caught looking at Microsoft sites at work Grin
Logged

Every time god kills an angel, I masturbate.

Pages: [1] 2   Go Up
Print
 
Jump to: