3 Replies - 3325 Views - Last Post: 31 July 2012 - 08:48 PM Rate Topic: -----

#1 mintzkie009  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 07-July 12

Help: How to transfer text string from one form to another?

Posted 31 July 2012 - 11:04 AM

Hello Good Evening Sir/Madam. First of all i would like to inform you that I'm just a beginner in VB. NET and I'm in the state of learning from scratch now. I started reading books and other references to learn the basics of VB. NET so I might be asking many basic question from now ^^ so please bear with me.

I was confused in my program here, I want to transfer the inputted string text from a from to display it to the other form. I made a class library here to code my function but to return the value of inputted string. But my problem is how can I display this string to the form.

I got 2 forms here and 1 class library.

frmMain - my main form and used to open the input form and display the text that is typed on input form (that should be the case but i got problems here)
frmInput - this serve as a input tool for the string.
ClassLibrary - my class (operation) and function (name) are here.


My Code:


------------------------------------

Imports ClassLibrary

Public Class frmInput

    Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click

        Operation.Name(txtBoxInput.Text)
        Me.Close()

    End Sub

End Class

-----------------------------------

Public Class Operation

    Public Shared Function Name(ByVal myname As String) As String

        Return myname

    End Function

End Class

-----------------------------------

mports ClassLibrary

Public Class frmMain

   
    Private Sub btnEnter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEnter.Click

        frmInput.Show()

    End Sub

    Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim display As String
        display = txtBoxName.Text
        Operation.Name(display)

    End Sub

End Class


---------------------------------

If my are wrong or not relevant to the topic, please give me sample of codes on how to do it.

This post has been edited by GunnerInc: 31 July 2012 - 08:51 PM
Reason for edit:: Added code tags


Is This A Good Question/Topic? 0
  • +

Replies To: Help: How to transfer text string from one form to another?

#2 DarenR  Icon User is offline

  • D.I.C Lover

Reputation: 497
  • View blog
  • Posts: 3,313
  • Joined: 12-January 10

Re: Help: How to transfer text string from one form to another?

Posted 31 July 2012 - 12:05 PM

put your code in [code] tags
Was This Post Helpful? 0
  • +
  • -

#3 Ryano121  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1363
  • View blog
  • Posts: 3,002
  • Joined: 30-January 11

Re: Help: How to transfer text string from one form to another?

Posted 31 July 2012 - 12:07 PM

How To Get Values From Form1 To Form2 (Or Any Other Forms).

Its in C# but you should be able to get something from it.
Was This Post Helpful? 0
  • +
  • -

#4 Vishal1419  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 141
  • Joined: 19-May 12

Re: Help: How to transfer text string from one form to another?

Posted 31 July 2012 - 08:48 PM

You have declared
Dim Display as String

Here Dim means Private
So you cannot use it in other forms

Declare the variable like this
Public Display as String

Your Declaration of Public Varible should be at the top of the form
I mean you should declare display at the top of the form

This Variable is Declared in frmMain

Now to use the value of this variable in frmInput
Just replace your code
Operation.Name(txtBoxInput.Text)

with this code
Operation.Name(frmMain.Display)


If you get any problems in doing this feel free to ask

This post has been edited by Vishal1419: 31 July 2012 - 08:49 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1