Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Visual Basic InputBox

Name: Anonymous 2007-12-04 15:11

I'm trying to create a program that takes input from the input box and then sends it to a textbox as a formatCurrency decimal. Whenever the loop ends, I get an error, "Input String was not in a correct format". Anybody know how to fix this?

Dim strTextBox As String
Dim decItemPrice As Decimal

Do

strTextBox = InputBox("Enter item price", "Item Price")
decItemPrice = Convert.ToDecimal(strTextBox)
txtItemPrice.Text = FormatCurrency(decItemPrice)

Loop Until strTextBox = ""

Name: Anonymous 2007-12-04 15:44

Anybody know how to fix this?
Yes.

Name: Anonymous 2007-12-04 16:01

Is that Haskell?

Name: Anonymous 2007-12-04 16:25

>>1
Step through your code, checking to see if the inputs are as you expect. Note the exact line that the error occurs on. If you still can't figure it out knowing the exact input on the exact line, post that information here, for summary mocking etc.

Name: Anonymous 2007-12-04 16:37

LOL.

Name: Anonymous 2007-12-04 16:40

The error occurs on line 7 --> decItemPrice = Convert.ToDecimal(strTextBox)

All calculations occur as expected, but I get an error.

Name: Anonymous 2007-12-04 16:55

>>6
And what is the value of strTextBox at this point?

Name: !MhMRSATORI 2007-12-04 18:05

script kiddie, go learn some Lisp and read SICP.

Name: Anonymous 2007-12-04 19:27

It's because you're trying to pass an empty string to the Convert.ToDecimal function, idiot moron!

Name: Anonymous 2007-12-04 22:06

>>8
You're Mr. Satori

Name: Anonymous 2007-12-04 22:09

Well, you made an obvious mistake. You're using VB

Name: Anonymous 2007-12-04 22:18

Well, you made an obvious mistake. You're using VB

Name: Anonymous 2007-12-04 22:19

Well, you obviously made a mistake. You're using VB

Name: Anonymous 2007-12-05 2:48

VB obviously made you. You're using a mistake well.

Name: Anonymous 2007-12-05 8:59

You were a mistake. VB's drink was spiked at a rave.

Name: Anonymous 2007-12-05 13:22

VB is for bitches.

Name: Anonymous 2007-12-06 0:30

>>16
Yes

Name: Anonymous 2007-12-06 1:24

>>15

i lol'd

Name: Anonymous 2007-12-06 18:02

vb = superior to lisp

Name: Anonymous 2007-12-06 18:05

>>19
I have to disagree. Lisp is superior to VB.

Name: Anonymous 2007-12-06 18:05

>>19
Somebody needs to write Visual Lisp for massive win.

Name: Anonymous 2007-12-06 20:58

>>21
http://www.lsharp.org/samples.html

(if (< (Hour (Now DateTime)) 12)

    (WriteLine Console "Good Morning")

    (WriteLine Console "Good Afternoon") )

Name: Anonymous 2007-12-06 21:12

>>21

But then you'd get a result similar to J#, which is massive lose.

Name: Anonymous 2007-12-06 21:25

>>23
Why so? It's not like Java would be involved.

Name: Anonymous 2007-12-06 21:36

>>24
J# = Java + .NET = Horrible enterprise mix

Name: Anonymous 2007-12-06 21:57

>>24
VL would not be (+ 'Java '.NET) though.

Name: Anonymous 2009-03-06 5:34

The Convert ToDecimal function.

Name: Anonymous 2010-11-15 6:48

Name: Anonymous 2010-12-27 2:50

Don't change these.
Name: Email:
Entire Thread Thread List