目前日期文章:20080712 (2)

瀏覽方式: 標題列表 簡短摘要
今天做了 解一元二次方程式

需要 button*2 textbox*4 label*3

程式碼 如下



Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim a, b, c, check As Integer
Dim ans1, ans2 As Double
a = Val(TextBox1.Text)
b = Val(TextBox2.Text)
c = Val(TextBox3.Text)
check = b * b - 4 * a * c
If check = 0 Then
ans1 = -b / (2 * a)
txtOutput.Text = "有兩個等根:" & ans1
ElseIf check < 0 Then
txtOutput.Text = "有兩個虛根"
Else
ans1 = (-b + Math.Sqrt(check)) / (2 * a)
ans2 = (-b - Math.Sqrt(check)) / (2 * a)
txtOutput.Text = "有兩個相異的實根:" & ans1 & "," & ans2
End If

End Sub

ip612256374 發表在 痞客邦 留言(1) 人氣()

上一次 做了 字體改變應用程式

這次 多了 功能表 與 字體大小

需要
menustrip*1 label*1

程式碼 如下

Public Class Form1

Private Sub 文字大小ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 文字大小ToolStripMenuItem.Click

End Sub

Private Sub mniType1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mniType1.Click
lblShow.Font = New Font("新細明體", lblShow.Font.Size, lblShow.Font.Style)
End Sub

Private Sub mniType2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mniType2.Click
lblShow.Font = New Font("標偕體", lblShow.Font.Size, lblShow.Font.Style)
End Sub

Private Sub mniSize1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mniSize1.Click
lblShow.Font = New Font(lblShow.Font.Name, 9, lblShow.Font.Style)
End Sub

Private Sub mniSize2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mniSize2.Click
lblShow.Font = New Font(lblShow.Font.Name, 12, lblShow.Font.Style)
End Sub

ip612256374 發表在 痞客邦 留言(0) 人氣()