tagCANDY CGI VBレスキュー(花ちゃん) の Visual Basic 2010 用 掲示板(VB.NET 掲示板)
VBレスキュー(花ちゃん) の Visual Basic 2010 用 掲示板(VB.NET 掲示板)
[ツリー表示へ]  [ワード検索]  [Home]

タイトル フォーム間の変数の受け渡し
投稿日: 2005/10/11(Tue) 19:31
投稿者raly pop
[OSのVer]:Windows2000    [VBのVer]:VB.NET  

他サイト、過去ログ等読んでいろいろ試しているのですが、停滞中なので、質問です。
form1のボタンを押すと、form2が開き、
同時にform1で宣言した変数に値が入るようになっています。
この変数をform2で使いたいのですが、うまくいきません。
ご教授願います。以下プログラム
---------------------------------------------------------------------------------------
form1

Public Class Form1
    Inherits System.Windows.Forms.Form
Windows フォーム デザイナで生成されたコード

Public aaa As Integer

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button1.Click
        aaa = 1
        Dim callform2 As New Form2
        Me.Hide()
        Try
            callform2.ShowDialog()

        Finally
            If Not callform2 Is Nothing Then
                callform2.Dispose()
                Me.Close()
            End If
        End Try

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button2.Click
        aaa = 2
        Dim callform2 As New Form2
        Me.Hide()
        Try
            callform2.ShowDialog()

        Finally
            If Not callform2 Is Nothing Then
                callform2.Dispose()
                Me.Close()
            End If
        End Try

    End Sub
End Class
------------------------------------------------------------------------------------------
form2
Public Class Form2
    Inherits System.Windows.Forms.Form
Windows フォーム デザイナで生成されたコード

  Public callform1 As Form1

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button3.Click
        
        callform1=New Form1
        Dim bbb As Integer
        
        bbb = callform1aaa

        Dim callform5 As New Form5
        Dim callform31 As New Form31

        If bbb = 1 Then
            callform5.ShowDialog()

        ElseIf bbb = 2 Then
            callform31.ShowDialog()

        End If

- 関連一覧ツリー をクリックするとツリー全体を一括表示します)

古いスレッドにレスはつけられません。