In the code example below, the function “FindData” will return list(“sublist”) of the objects having matchingKey same as viewstate value.
Dim sublist As List(Of MyClass)
sublist = allClient.FindAll(AddressOf FindData) ‘sublist will contain objects matching specified matching condition
Function FindData(ByVal b As MyClass) _
As Boolean
If (b.matchingKey = CInt(ViewState("matchingKey "))) Then ‘matching condition
Return True
Else
Return False
End If
End Function |
To deal with such scenario, you can find “ParameterDirection.ReturnValue”.
You can use this parameter direction to read the return value of the stored procedure.
Following example can make it more clearer.
In case, you have following or similar type of return statement somewhere in your stored procedure.
Return -999
To read this value, following code works,
Dim result As Integer = 0
Dim retValParam As New SqlClient.SqlParameter("@RETURN_VALUE", SqlDbType.Int)
retValParam.Direction = ParameterDirection.ReturnValue
dbCommand.Parameters.Add(retValParam)
database.ExecuteNonQuery(dbCommand)
result = retValParam.Value ‘ here the result must contain the returned value. In this case, it will be -999
Thanks,
Bhakti Shah |
The default size of Integer data type is 32 bit. |
NOTE: This is objective type question, Please click question title for correct answer. |
Label1.Font.Size = 12
Label1.Font.Name = "Broadway" |
With some scenarios you need to assign width to the controls rubtime. Generally we tend to make it soecified with percentage. At runtime we can use following way to make such assignments.
Label1.Width = Unit.Percentage(12.12)
You can have “pixel” or “point” as measurement unit and get your desired result set. |
Sometimes, you need to bind data using ternary functions from code file. With VB, you can achieve this thing using IIF function.
For an example, here in code below at the time of databinding I need to check value of “testString”. If the value is null/empty string it shows “NA” else the value.
<%#IIf(String.IsNullOrEmpty(DataBinder.Eval(Container.DataItem, "testString")), "NA", DataBinder.Eval(Container.DataItem, " testString "))%>
You can achieve the same result from code behind by placing appropriate code in itemdatabound method.(if applicable) |
|
NOTE: This is objective type question, Please click question title for correct answer. |
|
|
Fix is a function available in VB, which returns integer part of the number. |
Both of them returns integer part of the provided number. Difference lies, how they deal with the negative numbers.
Fix returns the first negative integer greater than or equal to provided Number while Int returns the first negative integer less than or equal to provided Number.
For an example,
Int(-99.2) ' Returns -100.
Fix(-99.2) ' Returns -99. |
"Test..Bore..gHere"
Justification : here we have used is MID statement not the MID function. |
Mid function returns the characters while the Mid statement replaces the characters. |
Said both performs the same type of operation on string. The basic difference lies, how they indice the string characters.
In case, if you have got string "TEST", the MID function will indice the characters as 1,2,3,4. But with String.substring they will be indiced as 0,1,2,3. |