visual basic 請高手教路(急!!!)

2008-09-21 10:44 am
新手唔知點樣開始寫好><",請各位幫幫忙教路
Write a program that determines the volume of a sphere given the radius by the user.(Note:There is a constant math.Pi that defines the value of π)
sphere volume: V=4/3πr^3

回答 (2)

2008-09-21 6:23 pm
✔ 最佳答案
如果用 console program 寫:

Sub Main()

Dim radius as double
Dim volume as double
Console.Write("Please enter the radius of the sphere: ")
radius=Console.ReadLine()
volume= 4 / 3 * Math.PI * radius^3
Console.WriteLine("The volume of sphere is " & volume)

End Sub
2008-09-21 5:24 pm
整個form啦 基本:整兩個text box 一個可以write個名就叫T1
另一個吾俾write(read only)就叫t2啦
write果個就係入 radius果個啦 readonly果個係output data
再整多個button 叫b1
Public Class Form1
Const Pi As Integer = 3.1416
Private Sub B1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
T2.Text = (Int(T1.Text) ^ 3) * 4 / 3 * Pi
End Sub
End Class

整段source copy落去就得架啦


收錄日期: 2021-05-03 11:38:04
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20080921000051KK00300

檢視 Wayback Machine 備份