Private Sub Command1_Click()
目前創(chuàng)新互聯(lián)已為千余家的企業(yè)提供了網(wǎng)站建設(shè)、域名、虛擬空間、網(wǎng)站運(yùn)營、企業(yè)網(wǎng)站設(shè)計、宣城網(wǎng)站維護(hù)等服務(wù),公司將堅持客戶導(dǎo)向、應(yīng)用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶和合作伙伴齊心協(xié)力一起成長,共同發(fā)展。
Dim a(4, 4) As Double
Dim sum1 As Double
For i = 1 To 4
sum = 0
For j = 1 To 4
a(i, j) = Format(Rnd * 89 + 10, "0")
sum = sum + a(i, j)
Print a(i, j);
Next j
Print sum
Next i
For j = 1 To 4
sum = 0
For i = 1 To 4
sum = sum + a(i, j)
Next i
Print sum;
Next j
End Sub
連每個數(shù)都輸出了,你自己運(yùn)行一下看看。
用循環(huán)啊
Private?Sub?Button1_Click(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?Button1.Click
Dim?count?As?Integer?=?Me.DataGridView1.Rows.Count
Dim?sum?As?Double?=?0
For?i?=?0?To?count?-?1
sum?+=?Val(Me.DataGridView1.Item("Amount",?i).Value)
Next
MsgBox("和是:"??sum)
End?Sub
現(xiàn)在的表格都有求和功能,就是把鼠標(biāo)放在你想求和的數(shù)字上,連續(xù)數(shù)字按住鼠標(biāo)往下拉,拉到結(jié)束的地方,在表格的右下角就會出現(xiàn)你要求的和
Dim textColumn As New DataGridViewTextBoxColumn() '定義一個新的textbox格式的列
textColumn.Name = "Column1" '定義該列的Name
textColumn.HeaderText = "Column1" '定義該列的標(biāo)題
DataGridView1.Columns.Add(textColumn)
For Each r As DataGridViewRow In DataGridView1.Rows '循環(huán)DataGridView的行
r.Cells(textColumn.Index).Value = r.Cells(0).Value + r.Cells(1).Value '將第一列和第二列單元格數(shù)據(jù)相加,并顯示在新添加的單元格上
Next
Private Sub Command1_Click()
MsgBox CalcResult(2)
End Sub
Public Function CalcResult(X As Long) As Double
Dim dblMinLevel As Double
Dim dblItem As Double
Dim dblN As Double
Dim dblMember As Double, dblBase As Double
Dim i As Double
Dim dblResult As Double
dblMinLevel = 10 ^ (-6)
dblN = 0
Do
dblMember = X ^ dblN
dblBase = 1
i = dblN
Do While i 1
dblBase = dblBase * i
i = i - 1
Loop
dblItem = dblMember / dblBase
dblResult = dblResult + dblItem
dblN = dblN + 1
Loop While dblItem = dblMinLevel
CalcResult = dblResult
End Function