用1个按钮在文本框之间切换

时间:2015-11-10 20:41:37

标签: vb.net

上下文:即时通讯制作骰子游戏,目标是我输入我想要的投掷次数(每次2个骰子),当我第一次点击按钮时,2个骰子被滚动,总数和图像滚动的骰子显示在玩家1下,当我第二次点击它同样的东西但在玩家2下......等等,直到玩家都滚动了我输入的次数。 https://gyazo.com/798aa46eb1eff6419811da7ca7ac8f9e链接到它的外观

问题:我不知道如何分开这两个并且有2个不同的总数。我的想法是以某种方式计算用户按下按钮的次数并使其成为可以设置限制(次数)并使用它来切换文本框,我只是不知道如何。提前感谢您的帮助。

Picmain1.Visible = True
    Picmain2.Visible = True
    Picdice1.Image = Nothing
    Picdice1_2.Image = Nothing
    Picdice2.Image = Nothing
    Picdice2_2.Image = Nothing
    picdice3.Image = Nothing
    picdice3_2.Image = Nothing
    picdice4.Image = Nothing
    picdice4_2.Image = Nothing
    picdice5.Image = Nothing
    picdice5_2.Image = Nothing
    picdice6.Image = Nothing
    picdice6_2.Image = Nothing
    Integer.TryParse(NumericUpDown1.Text, fois)
    nombre_aleatoire = MyRandomNumber.Next(1, 6)
        nombre_aleatoire2 = MyRandomNumber.Next(1, 6)
        TextBox1.Text &= Environment.NewLine & "ce jeu : " & total()
        total1 += total()
        lbltotal1.Text = "votre total est de :" & total1
        Select Case nombre_aleatoire
            Case 1
                Picmain1.Load("F:\new documents\Visual Studio 2015\Projects\mi-session\mi-session\Resources\dice-1.png")
            Case 2
                Picmain1.Load("F:\new documents\Visual Studio 2015\Projects\mi-session\mi-session\Resources\dice-2-md.png")
            Case 3
                Picmain1.Load("F:\new documents\Visual Studio 2015\Projects\mi-session\mi-session\Resources\dice-3-md.png")
            Case 4
                Picmain1.Load("F:\new documents\Visual Studio 2015\Projects\mi-session\mi-session\Resources\dice-4.png")
            Case 5
                Picmain1.Load("F:\new documents\Visual Studio 2015\Projects\mi-session\mi-session\Resources\dice-5.png")
            Case 6
                Picmain1.Load("F:\new documents\Visual Studio 2015\Projects\mi-session\mi-session\Resources\dice-6.png")
        End Select
        REM multilinetextbox 2
        nombre_aleatoire = MyRandomNumber.Next(1, 6)
    nombre_aleatoire2 = MyRandomNumber.Next(1, 6)
    Select Case nombre_aleatoire2
        Case 1
            Picmain2.Load("F:\new documents\Visual Studio 2015\Projects\mi-session\mi-session\Resources\dice-1.png")
        Case 2
            Picmain2.Load("F:\new documents\Visual Studio 2015\Projects\mi-session\mi-session\Resources\dice-2-md.png")
        Case 3
            Picmain2.Load("F:\new documents\Visual Studio 2015\Projects\mi-session\mi-session\Resources\dice-3-md.png")
        Case 4
            Picmain2.Load("F:\new documents\Visual Studio 2015\Projects\mi-session\mi-session\Resources\dice-4.png")
        Case 5
            Picmain2.Load("F:\new documents\Visual Studio 2015\Projects\mi-session\mi-session\Resources\dice-5.png")
        Case 6
            Picmain2.Load("F:\new documents\Visual Studio 2015\Projects\mi-session\mi-session\Resources\dice-6.png")
    End Select
    TextBox2.Text &= Environment.NewLine & "ce jeu : " & total()
    total2 += total()
    Lbltotal2.Text = "votre total est de :" & total2
End Sub

结束班

1 个答案:

答案 0 :(得分:1)

您可以使用变量并每次都切换它。

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          xmlns:android="http://schemas.android.com/tools"
          package="com.site.project" >

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >

        <activity
            android:name=".MainActivity"
            android:label="@string/app_name">

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>

        </activity>

    </application>

</manifest>

或者,如果您要跟踪卷数,可以使用Private _Player as byte = 1 ...In your button click IF _Player = 1 THEN Textbox1.Text = [Something] _Player = 2 else Textbox2.Text = [Something] _Player = 1 End if 运算符:

MOD