2008年8月27日 星期三

等差等比計算機(有缺陷版)



Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If ListBox1.SelectedItem = "等差數列" Then
If ListBox2.SelectedItem = "求合(請至少輸入首項公差(比)和項數)" Then
q.Text = n.Text * (2 * a1.Text + (n.Text - 1) * r.Text) / 2
End If
If ListBox2.SelectedItem = "求第N的質(請至少輸入首項公差第N項輸入至項數)" Then
q.Text = a1.Text + (n.Text - 1) * r.Text
End If
If ListBox2.SelectedItem = "求此數為第n項(同上 此數輸入至末項中)" Then
q.Text = -((-an.Text + a1.Text - r.Text) / r.Text)
End If
If ListBox2.SelectedItem = "求公差(公比)(請至少輸入首項第二項)" Then
q.Text = a2.Text - a1.Text
End If
If ListBox2.SelectedItem = "求公差(公比)(請至少輸入首項末項項數)" Then
q.Text = (an.Text - a1.Text) / (n.Text - 1)
End If

End If
If ListBox1.SelectedItem = "等比數列" Then
If ListBox2.SelectedItem = "求合(請至少輸入首項公差(比)和項數)" Then
q.Text = (a1.Text * (1 - r.Text ^ n.Text)) / (1 - r.Text)
End If
If ListBox2.SelectedItem = "求第N的質(請至少輸入首項公差第N項輸入至項數)" Then
q.Text = a1.Text * r.Text ^ (n.Text - 1)
End If
If ListBox2.SelectedItem = "求此數為第n項(同上 此數輸入至末項中)" Then
MsgBox("很抱歉我公式倒不出來所以不能用")
End If
If ListBox2.SelectedItem = "求公差(公比)(請至少輸入首項第二項)" Then
q.Text = a2.Text / a1.Text
End If
If ListBox2.SelectedItem = "求公差(公比)(請至少輸入首項末項項數)" Then
MsgBox("很抱歉我公式倒不出來所以不能用")
End If



End If
End Sub
End Class

沒有留言:

張貼留言