Solved

Pass variable value back to calling function -Easy

Posted on 2006-11-07
2
238 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 48

Accepted Solution

by:
AlexFM earned 250 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

752 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