Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Return Value and Stored Procedure Trouble

Hello. I am trying to Return the Integer Value of an Access Database Field and assign that value to an array variable so that I can compare that value to another variable. Here is my code. I am using Visual Studio 2005. I have been pulling my hair out for days on this. And I keep getting an error that says Expression Expected after a ByRef in my code. I put a remark statement in my code that shows you where the error is.

Public Class Form1
Dim QuestionNumber As Integer
Dim Answer(9) As Single
Dim Question(9) As Integer
Dim tableAdapter As New Math_TutorDataSetTableAdapters.AdditionTableAdapte r

Dim returnValue(9) As Integer

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'Math_TutorDataSet.Addition' table. You can move, or remove it, as needed.
Me.AdditionTableAdapter.Fill(Me.Math_TutorDataSet. Addition)
QuestionNumber = 0

End Sub

Public Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

returnValue(QuestionNumber)= CType(tableAdapter.GetDataBy3 (Byref Parameter1 as Integer) As Math_TutorDataSet.AdditionDataTable

' I am getting an error on the line above after GetDataBy3(ByRef
' ByRef is highlighted and says "Expression Expected"

If RadioButton1.Checked Then
Answer(QuestionNumber) = 1
End If
If RadioButton2.Checked Then
Answer(QuestionNumber) = 2
End If
If RadioButton3.Checked Then
Answer(QuestionNumber) = 3
End If
If RadioButton4.Checked Then
Answer(QuestionNumber) = 4
End If

If Answer(QuestionNumber) = returnValue(QuestionNumber) Then

Question(QuestionNumber) = 1
MsgBox(Question(QuestionNumber))

End If

End Sub

End Class

I am not even sure the rest of my code is correct to return a value. I have set up a stored procedure called GetDataBy3 and Parameter 1 set to Output. Any Help would be appreciated.

Thanks
[2126 byte] By [davidw] at [2007-11-11 8:34:34]
# 1 Re: Return Value and Stored Procedure Trouble
Well, your CType-statement looks erroneous.
The syntax is CType(Expression,Type)

I haven't studied the rest of your code, but The line that fails is definitely wrong. There should be no As. And check number of parenthesis.
etoostr at 2007-11-11 21:47:18 >
# 2 Re: Return Value and Stored Procedure Trouble
Well, your CType-statement looks erroneous.
The syntax is CType(Expression,Type)

I haven't studied the rest of your code, but The line that fails is definitely wrong. There should be no As. And check number of parenthesis.

Thank you for your response. I am so confused right now with this ReturnValue function. Basically what I am doing is writing a multiple choice test where the math problems and answers are stored in a database. There are for choices(RadioButton 1..4). When the user clicks on a RadioButton, the click event will determine which button the user clicked, and assign that as Answer(QuestionNumber). Then I want to pull the correct answer from the database, which is either 1,2,3, or 4 and compare the users answer to the value in field 4 of my database. So, what I should be able to do is when I run the program, read column 4 into an array. I created a query on clumn 4 and set up a parameter called parameter 1. The direction is output. I am just so confused. The MSDN help with VisualStudio 2005 is not helping me very much, LOL.

Thanks.
davidw at 2007-11-11 21:48:18 >