0

我想输入方法条件。首先我有一个变量“A”我给一个默认值0000,我在文本框中输入变量“B”和变量“N”作为计算公式,如果我在文本框中输入的是数字,直接到“IF B = Length (1)”的状态,并读取变量A的值“000”,然后遵循公式“N = A + B”。. 最后,当我按下按钮时,这些计算的结果上出现了。如何构造程序?我拥有如下所示的结构

Public Class uckondisi

#Region "variabel"
    Private _bilangan As Integer = "0000"
    Private _inputan As Integer = 0
#End Region

#Region "property"
    Public Property bilangan As Integer
        Get
            Return Me._bilangan
        End Get
        Set(value As Integer)
            Me._bilangan = value
        End Set
    End Property

    Public Property inputan As Integer
        Get
            Return Me._inputan
        End Get
        Set(value As Integer)
            Me._inputan = value
        End Set
    End Property
#End Region



    Private Sub btnproses_Click(sender As System.Object, e As System.EventArgs) Handles btnproses.Click

        If Me.txtinputan.Text = 1 Then
            _bilangan = "000"
            Me.txthasil.Text = inputan + bilangan

        Else
end sub
end class
4

1 回答 1

0

我不确定我是否理解您的问题,但您的代码中有一个明显的问题。

更新:

Private Sub btnproses_Click(sender As System.Object, e As System.EventArgs) Handles btnproses.Click

        If Me.txtinputan.Text = "1" Then
            _bilangan = 000
            Me.txthasil.Text = inputan + bilangan

        End If
End Sub

注意“

值(即数字)不需要“1”,但字符串需要。

文本框显示文本(即字符串),这意味着它需要“1”

如果你想要一个值,你可以使用:

If Val(txtinputan.Text) = 1 Then
    'Do something
End If
于 2013-10-10T09:28:04.423 回答