|
-
Nov 18th, 2017, 09:42 AM
#7
Re: Need help with calculator
I edited your original post to remove the italics and replace those tags with [CODE][/CODE] tags. The CODE tags nicely format the code (or at least a bit nicer format). Since you used Italics, you already know about the buttons. The CODE tags are the # button. The VB button (looks like VE on some browsers) adds color and numbering, so that's an option, as well.
I'm not sure that I agree with that last post. Normally, I'd be all for proper conversion, but in this case, why not just use a NumericUpDown control and get the Value property? Sure, you'd still have to do a conversion, since the value from a NUD is a Decimal, but CInt would be totally safe for that. It seems like a change such as that might show initiative, even though the teacher is allowing you to be a bit sloppy. Unless your teacher REQUIRES you to use a Textbox, you should really consider using a NUD. Textboxes are for entering strings. Those strings can look like numbers, but they are still strings. A NUD is for entering numbers. You can set a min, a max, and whether or not you have decimal places. It's much better for numbers than a textbox.
One thing about working with strings is in this line:
Code:
lblDisplay.Text = txtBaseRent.Text + 27
A string + a string is the two strings concatenated together. The + operator combines strings. If you are getting a number out of that, then the compiler is smart enough to convert the string to a number, add the 27, then convert the result back to a string. That would be fortunate, because I've always felt that what it SHOULD do is convert the 27 to a string and concatenate the two strings together. That would give you interesting results.
Also, the Checked property of a radiobutton is already True or False. You don't need to compare it to True, because that would just be saying If True = True, or If False = True. Either way, the answer is on the left side of the = sign, so you don't need to bother with the "= True" part.
My usual boring signature: Nothing
 
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|