本文介绍了在文本框中计算给定年份的年龄的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个文本框,我会输入一年如'1986'我想计算给定年份的年龄请帮助我,
i have a textbox , i would entered a year like'1986' i want to calculated age year from given year please help me,
推荐答案
Dim birthYear As Int32
If Int32.TryParse(txtAge.Text, birthYear) Then
Dim age As Int32 = Date.Now.Year - birthYear
MessageBox.Show("Your age is: " & age)
Else
MessageBox.Show("Please enter a valid year of birth")
End If
谢谢,
-RG
Thanks,
-RG
DIM txtYear AS String = "1986"
Console.WriteLine(DateTime.Now.Year - txtYear)
这篇关于在文本框中计算给定年份的年龄的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!