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
Solved

Pass variable value back to calling function -Easy

Posted on 2006-11-07
2
227 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 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

809 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