一个值的Visual Basic按钮 [英] Visual Basic Button with a Value
问题描述
林新本等,我woundering如果你可以让一个按钮等于一旦点击一个值。继承人什么Iv'e得到了
的一个实例:
Im new to this etc, and I was woundering if you can make a button equal a value once clicked. Heres what Iv'e got for an exmple:
公共类Form1中
Private Sub BuyButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BuyButton.Click
Dim MoneyBtn1 As String
Btn10p.PerformClick = MoneyBtn1
MoneyBtn1 = 0.1 + AmountTextBox.Text
Dim Cost, Amount, Change As Decimal
Dim Pennies, Pounds As Integer
Dim msg As String
Cost = Decimal.Parse(CostTextBox.Text)
Amount = Decimal.Parse(AmountTextBox.Text)
Change = (Amount - Cost)
If Change < 0 Then
msg = "You don't have enough Money"
Else
Pounds = Math.Floor(Change)
Pennies = (Change - Pounds) * 100
msg = "Your change is: " & Change.ToString("##.00") & Environment.NewLine
msg += "Pounds: " & Pounds & vbNewLine
msg += "Pennies: " & Pennies & vbNewLine
End If
ChangeLabel.Text = msg
End Sub
End Class
答案我已经使用:
私人小组Btn10p_Click(BYVAL发件人为System.Object的,BYVAL E上System.EventArgs)把手Btn10p.Click
AmountTextBox.Text = AmountTextBox.Text + 0.1
结束小组
Answer I have used: Private Sub Btn10p_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn10p.Click AmountTextBox.Text = AmountTextBox.Text + 0.1 End Sub
推荐答案
你的意思是在一个按钮上的文本?或者你只是想不止一个click事件的详细执行相同的增量常规?如果是后者的话
Do you mean the text on a button? Or do you simply want more than one click event to perform the same increment routine? If the latter then
Private Sub BuyButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BuyButton.Click
IncrementValue()
--Other stuff.
End Sub
Private Sub SomeOtherButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SomeOtherButton.Click
IncrementValue()
End Sub
Private Sub IncrementValue()
TextBox.Text = (Decimal.Parse(TextBox.Text) + 0.1).ToString
End Sub
如果这不是你在做什么,然后后,你需要你想要什么解释更好的细节。
If that's not what you're after then you need to explain exactly what you want in better detail.
这篇关于一个值的Visual Basic按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!