Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
Passing variables in VB?
Error 3 Option Strict On disallows narrowing from type 'Decimal' to type 'Integer' in copying the value of 'ByRef' parameter 'result' back to the matching argument. C:\Users\Administrator\Documents\Visual Studio 2008\Projects\TileLimited\TileLimited\Form1.vb 21 44 TileLimited
Could someone explain this and give me an example syntax? I looked at the MSDN, and I don't understand.
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ButtonCalculate.Click
'declare variables
Dim Length As Integer
Dim Width As Integer
Dim Area As Integer
Dim Price As Integer
Dim TotalPrice As Integer
'assign input to variables
Decimal.TryParse(TxtBoxLength.Text, Length)
Decimal.TryParse(TxtBoxWidth.Text, Width)
Decimal.TryParse(TxtBoxPrice.Text, Price)
'perform calculations
Area = Length * Width
TotalPrice = Price * Area
'display calculated results
LabelArea.Text = Convert.ToString(Area)
LabelTotalPrice.Text = Convert.ToString(TotalPrice)
3 Answers
- Anonymous1 decade agoFavorite Answer
It is pretty basic but can be confusing.
1) You are using the "Strict" option which eliminates converion of basic types.
2) In the function you have a integer parameter called result.
3) In calling the function you are giving it a Decimal variable where it was expecting the Integer
Because of Strict, it will not let you pass a decimal to an integer.
You either have to change the variable you are passing, e.g., CInt(variable), or change the sub to receive a decimal.
dim x as decimal
myFunc(CInt(x))
private sub myFunc(byRef decimalVar as decimal)
- 1 decade ago
Post the code please:
it is possible that the variable you are using in invalid passing to other variable, from decimal to integer or to integer to decimal.
- Anonymous4 years ago
create a string variable and populate it with the information from tb1, then, utilising the comparable variable set the fee of tb2 to the fee of the string. make valuable your string is asserted on the perfect point so which you will get right of entry to it exterior of it incredibly is determine technique in case you're utilising 2 diff processes.