vb輸入圓半徑求圓的面積 VB中如何寫程序代碼計算圓的面積?
VB中如何寫程序代碼計算圓的面積?A:試試這個:private sub formuuuload()dim R,s as longR=Val(InputBox(“please input the rad
VB中如何寫程序代碼計算圓的面積?
A:試試這個:
private sub formuuuload()
dim R,s as long
R=Val(InputBox(“please input the radius”,“calculate the area of the circle”,1))
s=3.14*R*R
print“the area of the circle is:“s
end sub
]”直接把這個代碼復制到代碼區(qū),然后單擊窗體輸入任意值以獲得圓的面積私有子窗體uClick()dim x As Integer,PI As single,PI=3.1415926 x=InputBox(“enter radius of a circle”)y=3.14*x*msgbox“圓的面積為:”¥d sub
首先,創(chuàng)建一個帶有兩個標簽的窗體form1。標題分別是“輸入圓的半徑”和“圓的面積:”兩個文本,文本屬性是,命令按鈕cmdsqr添加了其代碼private sub cmdsqr Click()text2。Text=3.1415926*val(Text1。文字)^2末端sub作為布局,我相信你會做得很好
private sub command1uClick()
d=InputBox(“please enter the diameter of the circle”
s=3.1415926/4*d^2
l=3.1415926*d
msgbox(“area of the circle”& s& vbcrlf&“perior of the circle”& l)
end sub
private sub command2u單擊()
r=InputBox(“請輸入圓半徑”
s=3.1415926*(r^2)
l=2*3.1415926*r
msgbox(“圓面積”&;s&vbcrlf&;“圓周長”&;l)