本文主要是介绍VB学习第四周续--四位整数逆序,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
四位整数逆序:
Public Class Form1Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPressDim n, a, b, c, d, m As IntegerIf Asc(e.KeyChar) = 13 Thenn = Val(TextBox1.Text)a = n Mod 10 '个位b = n \ 10 Mod 10 '十位c = n \ 100 Mod 10 '百位d = n \ 1000m = a * 1000 + b * 100 + c * 10 + dLabel2.Text = "逆序后整数为:" & mEnd IfEnd SubPrivate Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChangedIf Not IsNumeric(TextBox1.Text) ThenMsgBox("输入有非数字字符,请重新输入", , "数据检验")TextBox1.Text = ""TextBox1.Focus()End IfEnd SubPrivate Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.LoadEnd Sub
End Class
这篇关于VB学习第四周续--四位整数逆序的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!