Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Pass variable value back to calling function -Easy

Posted on 2006-11-07
2
Medium Priority
?
249 Views
Last Modified: 2010-04-23
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(sopnum)  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.Connection = 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
0
Comment
Question by:mwalsh2000
2 Comments
 
LVL 48

Accepted Solution

by:
AlexFM earned 1000 total points
ID: 17891440
Public Sub itemcount(ByRef sopnum As String)
0
 
LVL 13

Expert Comment

by:newyuppie
ID: 17891501
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
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question