Return Me.NumberOfPizzas + " Pizzas @ 8.99 " _
+ Me.NumberOfPizzas * 8.99 _
+ Me.NumberOfCokes + " Cokes @ $.99: " _
+ Me.NumberOfCokes * 8.99 _
+ " Order Amount: " + Me.getOrderAmount _
+ " Sales Tax: " _
+ Me.PRICONSTSALESTAX * Me.getOrderAmount _
+ " Amount Due: " + Me.getTotalAmount _
+ " Amount Paid: " _
+ Me.CustomerMoney(pridblCustomerMoney) _
+ " Change Due: " _
+ Me.changeDue(pridblCustomerMoney)
There is the code. The code is VB .NET. I am getting the following error:
Option Strict On disallows implicit conversion
The line that is giving the error is " Pizzas @ 8.99 ". Does anyone know
why I am getting this error? The method that this code is in is
Public Overrides Function toString() As String
Thanks!
a programming error
Moderator: paula
- Paco103
- Single White Admin
- Posts: 629
- Joined: January 15, 2004, 9:22 pm
- Location: Right Here
- Contact:
I'm not a VB expert - but what I see is Me.NumberOfPizzas is an integer, and you're trying to concatenate it into a string. Usually these will convert to a string type automatically, but it is the first variable in the function, so the compiler is probably thinking that it's an add function, not a concatenation.
Things to check:
Is + the proper concatenator in VB.Net? I know in ASP when using VB it's the & operator.
The option explicit message sounds like perhaps you have to manually define the conversion from an integer to a string?
Other thing to try would be to start the return function with an empty string, so that the first operand is the type you're trying to return. Just thoughts - as I said I'm not a VB expert.
Things to check:
Is + the proper concatenator in VB.Net? I know in ASP when using VB it's the & operator.
The option explicit message sounds like perhaps you have to manually define the conversion from an integer to a string?
Other thing to try would be to start the return function with an empty string, so that the first operand is the type you're trying to return. Just thoughts - as I said I'm not a VB expert.
What you said fixed my problem. Thanks.
In VB .NET, you can use the (+) to concatenate, but like you said,
the first thing that I typed after the return statement was a
function that returned an integer variable, so by using the
(+) VB .NET thought I was wanting to add and when it got
to the string, VB .NET didn't know how to add an integer
number to "Pizzas @ 8.99".
But, also in VB .NET, you can use the (&) to concatenate which
really is supposed to be use for concatenation all the time,
but if you are returning a bunch of methods that return strings,
I found that the (+) will concatenate, but in this instance it did
not work.
Thanks again,
Kevin
In VB .NET, you can use the (+) to concatenate, but like you said,
the first thing that I typed after the return statement was a
function that returned an integer variable, so by using the
(+) VB .NET thought I was wanting to add and when it got
to the string, VB .NET didn't know how to add an integer
number to "Pizzas @ 8.99".
But, also in VB .NET, you can use the (&) to concatenate which
really is supposed to be use for concatenation all the time,
but if you are returning a bunch of methods that return strings,
I found that the (+) will concatenate, but in this instance it did
not work.
Thanks again,
Kevin