URGENT-NEED HELP-PROJECT DUE TODAY AT SCHOOL

I have been working for the past 6 hrs on a project that is due today (12/19/08). I can't afford to get a zero for it. Please tell me what I did wrong in my code so I can fix it. We've just started writing functions and we're supposed to use them to calculate the balance. I'm done with all of the code except for mnuFileClr (it clears the form) and mnuFileSum (It gives you the summary in a message box). I just can't get these functions to work. I have attached a screen shot of the form. Please help!

Code:
____________________________________________________________________________
Option Explicit
Const mcurSvcChrg As Currency = 10#
Dim mcurBalance As Currency
Dim mcurChkTot As Currency
Dim mcurDepTot As Currency
Dim mintChkCount As Integer
Dim mintDepCount As Integer

'These will run at form load
Private Sub Form_Load()
'Centres the form on the screen
frmCA.Left = FNV(FNV(FNV(Screen.Width) - FNV(frmCA.Width)) / FNV(2))
frmCA.Top = FNV(FNV(FNV(Screen.Height) - FNV(frmCA.Height)) / FNV(2))
End Sub

Private Sub mnuEditColor_Click(Index As Integer)
With dlgCommon
.Flags = cdlCCRGBInit
.Color = lblBal.ForeColor
.ShowColor
End With

lblBal.ForeColor = dlgCommon.Color
End Sub

Private Sub mnuEditFnt_Click(Index As Integer)
With dlgCommon
.Flags = cdlCFScreenFonts
.FontBold = lblBal.Font.Bold
.FontItalic = lblBal.Font.Italic
.FontName = lblBal.Font.Name
.FontSize = lblBal.Font.Size
.FontStrikethru = lblBal.Font.Strikethrough
.FontUnderline = lblBal.Font.Underline
.ShowFont
End With

With lblBal.Font
.Bold = dlgCommon.FontBold
.Italic = dlgCommon.FontItalic
.Name = dlgCommon.FontName
.Size = dlgCommon.FontSize
.Strikethrough = dlgCommon.FontStrikethru
.Underline = dlgCommon.FontUnderline
End With
End Sub

Private Sub mnuFileSum_Click(Index As Integer)
If lblBal.Caption = "" Then
MsgBox "You can't get a summary if you don't first make a transaction! Please make a transaction before attempting to calculate a summary.", vbCritical, "CA - Error"
Exit Sub
End If

MsgBox "", vbInformation, "CA - Summary"
End Sub

Private Sub mnuFileTrans_Click(Index As Integer)
If IsNumeric(txtAmt.Text) Then
Else
MsgBox "Please type in a numeric value between 0 and 32,767.", vbCritical, "CA - Error"
Exit Sub
End If

If InStr(txtAmt.Text, " ") Or InStr(txtAmt.Text, "/") Or InStr(txtAmt.Text, "*") Or InStr(txtAmt.Text, ",") Or InStr(txtAmt.Text, "|") Or InStr(txtAmt.Text, "=") Or InStr(txtAmt.Text, "&") Or InStr(txtAmt.Text, "") Then
MsgBox "You used a forbidden character. Please retype your transaction without using any slashes, dollar signs, equal signs, commas, and/or spaces.", vbCritical, "CA - Error"
Exit Sub
Else
End If

If txtAmt.Text = "" Or txtAmt.Text = " " Or txtAmt.Text = "-" Or txtAmt.Text = "+" Then
MsgBox "Please type in a numeric value between 0 and 32,767.", vbCritical, "CA - Error"
Exit Sub
ElseIf IsNumeric(txtAmt.Text) Then
If Val(txtAmt.Text) <= 0 Or Val(txtAmt.Text) >= 32767 Then
MsgBox "Please type in a numeric value between 0 and 32,767.", vbCritical, "CA - Error"
Exit Sub
Else
If optDep.Value = False And optChk.Value = False And optSvcChrg.Value = False Then
MsgBox "Please specify what type of transaction is taking place.", vbCritical, "CA - Error"
Exit Sub
ElseIf optDep.Value = True Then
' mnuFileSum.Item.Enabled = True
mintDepCount = FNV(FNV(mintDepCount) + FNV(1))
lblBal.Caption = FCV(Dep(FCV(txtAmt.Text), FCV(lblBal.Caption), FCV(mcurDepTot)))
Exit Sub
ElseIf optChk.Value = True Then
' mnuFileSum.Item.Enabled = True
mintChkCount = FNV(FNV(mintChkCount) + FNV(1))
lblBal.Caption = FCV(Chk(txtAmt.Text, lblBal.Caption, mcurChkTot))
Exit Sub
ElseIf optSvcChrg.Value = True Then
' mnuFileSum.Item.Enabled = True
lblBal.Caption = FCV(SvcChg(mcurSvcChrg, lblBal.Caption))
Exit Sub
Else
' End If
' End If
' End If
End If
MsgBox "Please type in a numeric value between 0 and 32,767.", vbCritical, "CA - Error"
Exit Sub
End If
End If
' End If

MsgBox "An error has occured. Please clear the form and try again. If the problem persists, please contact the programmer at [email protected]", vbCritical, "CA - Error"
End Sub
'FCV (FormatCurrencyVal) | Use: Format the value of something as if it were a currency
Public Function FCV(ByVal curValue As Currency) As Currency
FCV = FormatCurrency(Val(curValue))
End Function
'FNV (FormatNumberVal) | Use: Format the value of something as if it were a number
Public Function FNV(ByVal intValue As Integer) As Integer
FNV = FormatNumber(Val(intValue))
End Function
'Calculates the balance for Deposits
Private Function Dep(ByVal curInput As Currency, ByVal curOutput As Currency, ByVal mcurTotal As Currency) As Currency
Dep = FCV(FCV(curOutput) + FCV(curInput))
mcurTotal = FCV(FCV(mcurTotal) + FCV(curInput))
' curOutput = FCV(Dep)
End Function
'Calculates the balance for Checks
Private Function Chk(ByVal curInput As Currency, ByVal curOutput As Currency, ByVal mcurTotal As Currency) As Currency
Chk = FCV(FCV(curOutput) - FCV(curInput))
mcurTotal = FCV(FCV(mcurTotal) + FCV(curInput))
' curOutput = FCV(Chk)
End Function
'Calculates the balance for Service Charges
Private Function SvcChg(ByRef mcurServiceCharge As Currency, ByVal curOutput As Currency) As Currency
SvcChg = FCV(FCV(curOutput) - FCV(mcurServiceCharge))
' curOutput = FCV(SvcChg)
End Function

Private Sub mnuFileEnd_Click(Index As Integer)
End
End Sub

Private Sub optSvcChrg_Click()
If optSvcChrg.Value = True Then txtAmt.Enabled = False Else txtAmt.Enabled = True
End Sub
___________________________________________________________________________

Comments

  • Private Sub mnuFileSum_Click(Index As Integer)
    If lblBal.Caption = "" Then
    MsgBox "You can't get a summary if you don't first make a transaction! Please make a transaction before attempting to calculate a summary.", vbCritical, "CA - Error"
    Exit Sub
    ELSE 'Continue the IF with ELSE As the label has content
    MsgBox "", vbInformation, "CA - Summary"
    END IF 'Now we can end the IF
    End Sub


  • Thanks it works! I might get an A now.
  • No problem man, its always the simple things we overlook :) Glad to be of help.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories