Quantcast
Channel: Visual Studio and Visual Web Developer Express
Viewing all articles
Browse latest Browse all 3509

How to pass the value of one variable from one sub to another sub in vb.net

$
0
0

Hello

I am still new to vb.net programming and trying to pass value from one sub to another sub.

In the below coding I have declared the variable SurveyID which stores the value of survey.

    Protected Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click

        Dim survey = Guid.NewGuid().ToString()

        Dim SurveyTitle As String = "Diversity Monitoring Survey"
        Dim SurveyDetail As String = ""

        Dim SurveyID As String = survey
 
       Core.DB.DoQuery("insert into survey(id,title, detail,employerid,userid) values(@id,@title, @detail, @eid, @uid);", Core.DB.SIP("title", SurveyTitle), Core.DB.SIP("detail", SurveyDetail), Core.DB.SIP("eid", LocalHelper.UserEmployerID()), Core.DB.SIP("uid", LocalHelper.UserID()), Core.DB.SIP("id", survey))

        Call AddQuestionCategoryRace()

        Response.Redirect("profile.aspx")


    End Sub

Now I want to use SurveyID in another sub. Bothe sub are under same partial class

    Private Sub AddQuestionCategoryRace()
        Dim SurveyQuestionCategoryTitle As String = "Diversity Monitoring Question"
        Dim SurveyQuestionCategoryDetail As String = " "
        Dim SID as string = SurveyId 


        Core.DB.DoQuery("insert into surveyquestioncategory(title, detail, surveyid) values(@title, @detail, @sid)", Core.DB.SIP("title", SurveyQuestionCategoryTitle), Core.DB.SIP("detail", SurveyQuestionCategoryDetail), Core.DB.SIP("sid", Survey))

        SQCID = Core.DB.GetScalar("SELECT id FROM surveyquestioncategory WHERE surveyid = '" & SID & "'")

    End Sub

How can I do that.

I am totally new to programming so forgive my ignorance and please suggest me accordingly.


Viewing all articles
Browse latest Browse all 3509

Trending Articles