VB.NET 学习---(5)

前端之家收集整理的这篇文章主要介绍了VB.NET 学习---(5)前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

下面的代码示例是一个事件处理程序,该处理程序在 Text 属性值更改时执行。 Control 类有几个名称模式为PropertyNameChanged方法,它们在相应的PropertyName值(PropertyName表示相应的属性名)更改时引发。

Private Sub currencyTextBox_TextChanged(sender As Object,_ 
  e As EventArgs) Handles currencyTextBox.TextChanged
   Try
      ' Convert the text to a Double and determine if it is a negative number.
      If Double.Parse(currencyTextBox.Text) < 0 Then
         ' If the number is negative,display it in Red.
         currencyTextBox.ForeColor = Color.Red
      Else
         ' If the number is not negative,display it in Black.
         currencyTextBox.ForeColor = Color.Black
      End If
   Catch
      ' If there is an error,display the text using the system colors.
      currencyTextBox.ForeColor = SystemColors.ControlText
   End Try
End Sub 
原文链接:https://www.f2er.com/vb/263226.html

猜你在找的VB相关文章