VB根据生日计算星座。

建立一个command1控件,一个text1控件选项显式函数constellation(byval m as date)as string '返回星座dim数as long number = month(m)* 100+day(m)。选择案号案321至419星座= "白羊座"案420至520星座= "金牛座"案521星座= "双子座"案622至722星座= "巨蟹座"案723至822星座= "狮子"案823至922星座= "处女"案923至1023星座。= "天秤座"格1024转1121星座= "天蝎座"格122转1221星座= "射手座"格65438+。o 1231 Constellation = " scorpion " Case 101 to 119 Constellation = " scorpion " Case 120 to 218 Constellation = "水瓶" c . ASE 219 to 320 Constellation = "双鱼座" Case Else Constellation = "没有这样的星座!"End select end function private子命令1 _ click()if is Date(trim(text 1))= true then msgbox constellation(trim(text 1))else msgbox“日期格式不对!”end if end sub private subform _ load()command 1 . caption = " constellation " text 1 = " 1547-7-7 " end sub。