Question sub arguments

paulthepaddy

Well-known member
Joined
Apr 9, 2011
Messages
222
Location
UK
Programming Experience
Beginner
hey guys i was using a sub routine like this
Private Sub discount(selectcar As car)
                lbl_Dis_add.Text = "Discount"
                Call selectcar.Calculate_SubTotal()
                selectcar.Discount = SSR_add_Minus.Value
                selectcar.Total = selectcar.Subtotal - selectcar.Discount
                Car_Price_Total.Value = selectcar.Total
    End Sub

but now it wont let me use it, i must use it as
Private Sub discount(ByVal selectcar As car)
                lbl_Dis_add.Text = "Discount"
                Call selectcar.Calculate_SubTotal()
                selectcar.Discount = SSR_add_Minus.Value
                selectcar.Total = selectcar.Subtotal - selectcar.Discount
                Car_Price_Total.Value = selectcar.Total
 End Sub

this happened after i did a format and reinstalled VS2010

any idea's? i tried messing with the rules but no luck
 
Last edited by a moderator:
The only difference I can see is that ByVal keyword appeared in method signature, this default passing mechanism is something that was hidden starting from VS 2010 SP1, so install that too. Installing the latest service packs is something you should do in any case.
 
ah right thank you, you said that it was hidden, does that mean that even though it is hidden it is still their, i ask this because i am getting error popping up about object reference isn't linked to an object and telling me to use the new keyword and the only diffrence i could see was the ByVal being forced into the sub arguments.

thanks im installing SP1 now
 
does that mean that even though it is hidden it is still their
Correct, it is the default passing mechanism for parameters.
ask this because i am getting error popping up about object reference isn't linked to an object
ByVal/ByRef has nothing to do with object references, only about variable pointers.
 
Back
Top