mwalsh2000
asked on
Pass variable value back to calling function -Easy
VS 2005, VB.NET I have the following function:
public sub getmethodid(sopnum,custid)
which calls the following function and passes the sopnum string variable:
validateOrder.itemcount(so pnum) the code for this function follows:
Module validateOrder
Public Sub itemcount(ByVal sopnum As String)
Dim cn As New SqlClient.SqlConnection()
Dim cmd As New SqlClient.SqlCommand()
Dim ad As New SqlClient.SqlDataAdapter
Dim strcn As String
Dim strSQL As String
Dim itmcnt As New DataSet
Dim row As DataRow
Dim vop10200cnt As String
strcn = My.Settings.STRL
cn.ConnectionString = strcn
strSQL = "select count(*) as cnt from vop10200 where sopnumbe = '" + sopnum + "'"
cmd.CommandText = strSQL
ad.SelectCommand = cmd
ad.SelectCommand.Connectio n = cn
ad.Fill(itmcnt)
cn.Close()
For Each row In itmcnt.Tables(0).Rows
vop10200cnt = (RTrim(row.Item("cnt")))
If vop10200cnt = 0 Then
Dim tableid As String = 1
orderLog(sopnum, tableid)
sopnum = "no go" <-------- here I am attempting to change the sopnum variable to "no go" but it does not change when passed back to getmethodid function, how can I send back the new variable value?
Else
getd10200cnt(sopnum, vop10200cnt)
End If
Next
End Sub
public sub getmethodid(sopnum,custid)
which calls the following function and passes the sopnum string variable:
validateOrder.itemcount(so
Module validateOrder
Public Sub itemcount(ByVal sopnum As String)
Dim cn As New SqlClient.SqlConnection()
Dim cmd As New SqlClient.SqlCommand()
Dim ad As New SqlClient.SqlDataAdapter
Dim strcn As String
Dim strSQL As String
Dim itmcnt As New DataSet
Dim row As DataRow
Dim vop10200cnt As String
strcn = My.Settings.STRL
cn.ConnectionString = strcn
strSQL = "select count(*) as cnt from vop10200 where sopnumbe = '" + sopnum + "'"
cmd.CommandText = strSQL
ad.SelectCommand = cmd
ad.SelectCommand.Connectio
ad.Fill(itmcnt)
cn.Close()
For Each row In itmcnt.Tables(0).Rows
vop10200cnt = (RTrim(row.Item("cnt")))
If vop10200cnt = 0 Then
Dim tableid As String = 1
orderLog(sopnum, tableid)
sopnum = "no go" <-------- here I am attempting to change the sopnum variable to "no go" but it does not change when passed back to getmethodid function, how can I send back the new variable value?
Else
getd10200cnt(sopnum, vop10200cnt)
End If
Next
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
or... turn the sub into a function that returns a string value, and return "no go", use this returned value on your getmethodid sub by calling the function itemcount and using its returned value