r/visualbasic • • Sep 22 '20

Please help! Code won’t execute when the calculate button is pressed, the text boxes remain blank. What am I doing wrong?

9 Upvotes

6 comments sorted by

2

u/Thunor_SixHammers Sep 23 '20

Why are you using tostring("c"); why not just

LblSubtotal.text = decSubtotal

1

u/jbstcyr Oct 05 '20

He is formatting the binary value to Currency.

2

u/kilburn-park Sep 23 '20 edited Sep 23 '20

Your title says that text boxes remain blank, but since you're using Hungarian notation for your control names, your code indicates that you're updating the labels and not the text boxes. Run your program again, but pay close attention to the labels next to the text boxes. If those are changing, then you're updating the wrong controls. You probably need to be setting, for example, txtRoomCharges.Text and not lblRoomCharges.Text.

Edit: I just looked at your code again and realized that the date and time are getting set correctly, so my first assumption was probably wrong. There are a few things things it could be, and /u/TotolVuela has the best advice for where to start looking. Just as a sanity check, are you getting an error message because the Try/Catch is trapping an exception?

1

u/TotolVuela Sep 23 '20

Either the button press event is not tied to it correctly or there is another piece in your code that may be overwriting the results. Have you stepped through the code to ensure the values are going into the labels?

1

u/infreq Sep 23 '20

Have you tried single-stepping it while looking at your variables? It will surely tell you where the problem is.

1

u/TCBW Jan 11 '21

I've had an issue in the past where the fields were updated but the screen did not refresh try lbl???.refresh