0
在過去的幾周裏,我一直在研究VB程序,每個作業都是爲了添加更多內容。直到本週,一切運行順利。現在突然間,程序顯示我的啓動畫面並跳到我的左右框,但沒有顯示我的主窗體。我沒有錯誤,它成功編譯並編譯。VB 2010沒有運行我的整個程序
Public Class Checkbook
Dim currentBalance As Decimal = CDec(500.0)
Dim depositAmount As Decimal
Dim checkAmount As Decimal
Dim serviceBalance As Decimal
Dim serviceFee As Decimal
Dim depositCount As Decimal
Dim serviceAmount As Decimal
Dim enteredAmount As Decimal
Function checkBalance() As Decimal
'this function allows the user to check their current balance
Dim enteredAmount As String = transAmount.Text
serviceFee = 10
balanceLabel.Text = currentBalance.ToString("C")
Return currentBalance
End Function
Function deposit() As Decimal
'this function adds the transaction amount to the balance
enteredAmount = Decimal.Parse(transAmount.Text)
depositAmount = (currentBalance + enteredAmount)
currentBalance = depositAmount
Summary.depositList.Items.Add(depositAmount)
balanceLabel.Text = currentBalance.ToString("C")
Return currentBalance
End Function
Function check() As Decimal
'this function takes the check amount and sbutracts its from the balance
enteredAmount = Decimal.Parse(transAmount.Text)
checkAmount = (currentBalance - enteredAmount)
currentBalance = checkAmount
Summary.amountList.Items.Add(checkAmount)
Return currentBalance
'gives a service charge if balance will be negative
If currentBalance < 0 Then
currentBalance = currentBalance - 10
Summary.feesList.Items.Add(serviceFee)
MessageBox.Show("Negative Balance Fee Applied", "Attention: Fee Incurred")
Return currentBalance
End If
End Function
Function service() As Decimal
'this transaction subtracts the service charge from the balance
enteredAmount = Decimal.Parse(transAmount.Text)
serviceAmount = (currentBalance - (10 + enteredAmount))
currentBalance = serviceAmount
Summary.amountList.Items.Add(serviceAmount)
balanceLabel.Text = currentBalance.ToString
Return currentBalance
End Function
Private Sub ExitToolStripMenuItem_Click(sender As Object, e As System.EventArgs) Handles ExitToolStripMenuItem.Click
'exits form
Me.Close()
End Sub
Private Sub AboutToolStripMenuItem_Click(sender As Object, e As System.EventArgs) Handles AboutToolStripMenuItem.Click
'gives information about program
AboutBox.Show()
End Sub
Private Sub SummaryToolStripMenuItem_Click(sender As Object, e As System.EventArgs) Handles SummaryToolStripMenuItem.Click
'shows summary of transactions
Summary.Show()
End Sub
Private Sub CalculateToolStripMenuItem_Click(sender As Object, e As System.EventArgs) Handles CalculateToolStripMenuItem.Click
'gives orders for what function to call
If balanceButton.Checked Then
Call checkBalance()
ElseIf checkButton.Checked Then
Call check()
ElseIf depositButton.Checked Then
Call deposit()
ElseIf serviceRadioButton.Checked Then
Call service()
End If
End Sub
Private Sub FontToolStripMenuItem_Click(sender As Object, e As System.EventArgs) Handles FontToolStripMenuItem.Click
'allows user to change font type and size
With FontDialog1
.Font = balanceLabel.Font
.ShowDialog()
balanceLabel.Font = .Font
End With
End Sub
Private Sub ColorToolStripMenuItem_Click(sender As Object, e As System.EventArgs) Handles ColorToolStripMenuItem.Click
'allows user to change font color
With ColorDialog1
.Color = balanceLabel.ForeColor
.ShowDialog()
balanceLabel.ForeColor = .Color
End With
End Sub
End Class
這聽起來像一個偉大的機會,熟悉Visual Studio的調試功能。將調試斷點放在應用程序中的戰略代碼行處,並以調試模式運行應用程序。它會暫停執行這些斷點,並允許您逐步執行正在運行的代碼,檢查變量的運行時值,並觀察運行時行爲。當這樣做的時候,這種行爲的具體表現與你期望的有什麼不同? – David
我的啓動畫面打開並運行,而不是運行我的實際程序窗體,它拉起我的關於窗體,這是我的主菜單上的主窗體上的一個按鈕。 – user3533298