Why the Print Report button won't calculate or

blueeyes53

Active member
Joined
May 2, 2006
Messages
25
Programming Experience
Beginner
:confused: Hi,
I am learning VisualBasic.NET, and so far I have worked on projects that included a ' Calculate" button, but now I started working in projects that includes creating a ' Splash' screen, and using the printpreview. I am working in my first project and it does not have a calculate button, but includes a Print Report button. I have place the code at the pdreport_printPage, but it does nothing. It does not calculate or do nothing what- so - ever. I am working on (or trying to :) )in a straight - line depreciation project.

Could anyone please help as why my code does nothing, or even shows on the previewreport page. All it shows in the ppr page is the initialValue 1000, it does not show "Year" 1, for Depreciation it just subtracted "AssetLife' which is 10 yrs., and the Endvalue is showing .00 . Am I placing the code in the right place or ..... what is there missing that the code is not doing nothing?

Thank you:confused:
 
welcome to the forums, i moved this topic to the Windows Forms section

first off we're going to need to see the code you've got for the button's click event and for the pdreport printpage event before we can help you

also just an fyi when posting code be sure use the [ code] [ /code] tags because it's easier to read that way, just highlight your code in the editer and click the "code" button to have it automatically add those tags for ya
 
Why the Print Report button won't calculate

JuggaloBrotha said:
welcome to the forums, i moved this topic to the Windows Forms section

first off we're going to need to see the code you've got for the button's click event and for the pdreport printpage event before we can help you

also just an fyi when posting code be sure use the [ code] [ /code] tags because it's easier to read that way, just highlight your code in the editer and click the "code" button to have it automatically add those tags for ya
I don't know how to use the For Loop... next
VB.NET:
[SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] pdReport_PrintPage([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Drawing.Printing.PrintPageEventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2] pdReport.PrintPage
 [/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] pintYear [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Integer
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] pdblInitialValue [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Double
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] pdblAssetLife [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Double
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] pdblSalvageValue [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Double
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] pdblTotalDepreciation [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Double
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] pdblAnnualDepreciation [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Double
 [/COLOR][/SIZE][SIZE=2]
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] pintLinesPerPage [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Integer
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] PintTotalLines [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Integer
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] PintCurrentLine [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Integer
 
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Call[/COLOR][/SIZE][SIZE=2] PrintPageTitles(e)
pintLinesPerPage = ToInt32(e.MarginBounds.Height / _
msngFontHeight) - 6
PintTotalLines = mdblDepreciation
msngPages = ToSingle(PintTotalLines / pintLinesPerPage + 1)
[/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] msngCurrentPage <= msngPages [/SIZE][SIZE=2][COLOR=#0000ff]Then
   [/COLOR][/SIZE][SIZE=2]msngYPos = e.MarginBounds.Top + (msngFontHeight * 5)
 [/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If
 
 [/COLOR][/SIZE][SIZE=2]msngYPos += mfntPrint.GetHeight(e.Graphics)
[/SIZE][SIZE=2][COLOR=#0000ff]Call[/COLOR][/SIZE][SIZE=2] DrawStringInBox(e, cintCol1Start, msngYPos, _
cintColWidth, msngYPos + msngFontHeight, _
mintCurrentYear.ToString("###"))
 [/SIZE][SIZE=2][COLOR=#0000ff]
Call[/COLOR][/SIZE][SIZE=2] DrawStringInBox(e, cintCol2Start, msngYPos, _
cintColWidth, msngYPos + msngFontHeight, _
mdblInitialValue.ToString("###,###.00"))
mdblDepreciation = mdblInitialValue - mdblSalvageValue / 10
[/SIZE][SIZE=2][COLOR=#0000ff]Call[/COLOR][/SIZE][SIZE=2] DrawStringInBox(e, cintCol3Start, msngYPos, _
cintColWidth, msngYPos + msngFontHeight, _
mdblDepreciation.ToString("###,###.00"))
[/SIZE][SIZE=2][COLOR=#0000ff]Call[/COLOR][/SIZE][SIZE=2] DrawStringInBox(e, cintCol4Start, msngYPos, _
cintColWidth, msngYPos + msngFontHeight, _
mdblEndValue.ToString("###,###.00"))
mintCurrentYear += 1
[/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] mdblInitialValue + mdblSalvageValue < mdblDepreciation [/SIZE][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][SIZE=2]msngYPos += mfntPrint.GetHeight(e.Graphics) * 2
[/SIZE][SIZE=2][COLOR=#0000ff]Call[/COLOR][/SIZE][SIZE=2] DrawStringInBox(e, cintCol3Start, _
msngYPos, cintColWidth, _
msngYPos + msngFontHeight, _
mdblDepreciation.ToString("###,##.00"))
e.HasMorePages = [/SIZE][SIZE=2][COLOR=#0000ff]True
 
 [/COLOR][/SIZE][SIZE=2]mdblInitialValue = ToInt32(txtInitialValue.Text)
mdblSalvageValue = ToDouble(txtSalvageValue.Text)
mdblAssetLife = ToDouble(txtAssetLife.Text)
mdblTotalDepreciation = mdblInitialValue - mdblSalvageValue
mdblAnnualDepreciation = mdblTotalDepreciation \ mdblAssetLife
 
 [/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If
 
[/COLOR][/SIZE][SIZE=2]msngCurrentPage += 1
e.HasMorePages = [/SIZE][SIZE=2][COLOR=#0000ff]False
 
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub
[/COLOR][/SIZE]
 
Last edited by a moderator:
Back
Top