hey guys i need a bit of help finishing my project,
can someone tell me if its possible to bring for example a bar graph made in word/excel into vb6? I needed to display data in a bar graph so i made it in word since i dont know if its possible to make one in Vb.(if it is please tell me how)
And my second question is that how would i do something like this
__________________________________________________________________
Print the precipitation data (in a neat table with headers and row indicators) to the screen
Hear is my main code if its any help, thanyou.
(and a word doc is attached, if u need more info on what im trying to do.)
Code:
Option Explicit
Function AverageNorth()
Dim intRow As Integer
Dim intCol As Integer
Dim dblSum As Double
intCol = 1
For intRow = 1 To 6
dblSum = dblSum + dblDataArray(intRow, intCol)
Next intRow
AverageNorth = dblSum / 6
End Function
Function AverageApril()
Dim intRow As Integer
Dim intCol As Integer
Dim dblSum As Double
intRow = 4
For intCol = 1 To 4
dblSum = dblSum + dblDataArray(intRow, intCol)
Next intCol
AverageApril = dblSum / 4
End Function
Private Sub cmdAnswerH_Click()
frmAnswerH.lblH.Caption = frmAnswerH.lblH.Caption & " " & _
seccondSmallest & "cm"
frmMainMenu.Hide
frmAnswerH.Show
End Sub
Function seccondSmallest()
Dim intRow As Integer
Dim intCol As Integer
Dim dblSum As Integer
Dim intCount As Integer
dblSum = 1
For intRow = 1 To 6
For intCol = 1 To 4
If (dblDataArray(intRow, intCol)) < dblSum Then
dblSum = dblDataArray(intRow, intCol)
End If
Next intCol
Next intRow
seccondSmallest = dblSum
End Function
Private Sub cmdC_Click()
frmAnswerC.lblC.Caption = frmAnswerC.lblC.Caption & " " & _
AverageNorth & "cm"
frmMainMenu.Hide
frmAnswerC.Show
End Sub
Private Sub cmdD_Click()
frmAnswerD.lblD.Caption = frmAnswerD.lblD.Caption & " " & _
AverageApril & "cm"
frmMainMenu.Hide
frmAnswerD.Show
End Sub
Private Sub cmdDisplay_Click()
frmDisplay.lbl11 = dblDataArray(1, 1)
frmDisplay.lbl12 = dblDataArray(1, 2)
frmDisplay.lbl13 = dblDataArray(1, 4)
frmDisplay.lbl14 = dblDataArray(1, 4)
frmDisplay.lbl21 = dblDataArray(2, 1)
frmDisplay.lbl22 = dblDataArray(2, 2)
frmDisplay.lbl23 = dblDataArray(2, 3)
frmDisplay.lbl24 = dblDataArray(2, 4)
frmDisplay.lbl31 = dblDataArray(3, 1)
frmDisplay.lbl32 = dblDataArray(3, 2)
frmDisplay.lbl33 = dblDataArray(3, 3)
frmDisplay.lbl34 = dblDataArray(3, 4)
frmDisplay.lbl41 = dblDataArray(4, 1)
frmDisplay.lbl42 = dblDataArray(4, 2)
frmDisplay.lbl43 = dblDataArray(4, 3)
frmDisplay.lbl44 = dblDataArray(4, 4)
frmDisplay.lbl51 = dblDataArray(5, 1)
frmDisplay.lbl52 = dblDataArray(5, 2)
frmDisplay.lbl53 = dblDataArray(5, 3)
frmDisplay.lbl54 = dblDataArray(5, 4)
frmDisplay.lbl61 = dblDataArray(6, 1)
frmDisplay.lbl62 = dblDataArray(6, 2)
frmDisplay.lbl63 = dblDataArray(6, 3)
frmDisplay.lbl64 = dblDataArray(6, 4)
frmMainMenu.Hide
frmDisplay.Show
End Sub
Function Average()
Dim intRow As Integer
Dim intCol As Integer
Dim dblSum As Double
intCol = 1
For intRow = 1 To 6
dblSum = dblSum + dblDataArray(intRow, intCol)
Next intRow
AverageNorth = dblSum / 6
End Function
Function TotalPercipitation()
Dim intRow As Integer
Dim intCol As Integer
Dim dblSum As Integer
For intRow = 1 To 6
For intCol = 1 To 4
dblSum = dblSum + dblDataArray(intRow, intCol)
Next intCol
Next intRow
TotalPercipitation = dblSum
End Function
Function LargestJune()
Dim intRow As Integer
Dim intCol As Integer
Dim dblSum As Integer
intRow = 6
For intCol = 1 To 4
If (dblDataArray(intRow, intCol)) > dblSum Then
dblSum = dblDataArray(intRow, intCol)
End If
Next intCol
LargestJune = dblSum
End Function
Private Sub cmdE_Click()
frmAnswerE.lblE.Caption = frmAnswerE.lblE.Caption & " " & _
TotalPercipitation & "cm"
frmMainMenu.Hide
frmAnswerE.Show
End Sub
Private Sub cmdExit_Click()
Unload frmAnswerC
Unload frmDisplay
Unload Me
End Sub
Private Sub cmdF_Click()
frmAnswerF.lblF.Caption = frmAnswerF.lblF.Caption & " " & _
LargestJune & "cm"
frmMainMenu.Hide
frmAnswerF.Show
End Sub
Function SmallestSouth()
Dim intFIleNum As Integer
Dim strData As String
Dim intRow As Integer
Dim intCol As Integer
Dim dblSum As Double
intCol = 3
dblSum = 100
For intRow = 1 To 6
If (dblDataArray(intRow, intCol)) < dblSum Then
dblSum = dblDataArray(intRow, intCol)
End If
Next intRow
SmallestSouth = dblSum
End Function
Private Sub cmdG_Click()
frmAnswerG.lblG.Caption = frmAnswerG.lblG.Caption & " " & _
SmallestSouth & "cm"
frmMainMenu.Hide
frmAnswerG.Show
End Sub
Private Sub cmdLoad_Click()
Dim intFIleNum As Integer
Dim strData As String
Dim intRow As Integer
Dim intCol As Integer
intFIleNum = FreeFile
Open (App.Path & "\" & "Precip.txt") For Input As #intFIleNum 'Open Assigns it to intfileenum
For intRow = 1 To 6
For intCol = 1 To 4
Input #intFIleNum, strData 'store
dblDataArray(intRow, intCol) = Val(strData)
Next intCol
Next intRow
Close #intFIleNum
End Sub
Private Sub cmdWrite_Click()
Dim index
Dim intFIleNum As Integer
Dim intRow As Integer
Dim intCol As Integer
intFIleNum = FreeFile
Open (App.Path & "\" & " precipe2.txt") For Output As #intFIleNum
For intRow = 1 To 6
For intCol = 1 To 4
Print #intFIleNum, dblDataArray(intRow, intCol)
Next intCol
Next intRow
Close #intFIleNum
End Sub
Last edited by cruisx; Dec 19th, 2007 at 07:53 PM.
Easiest would be to use the Microsoft Chart Control 6.0
If it's not in your project, just load it:
Project/Components/Browse/Checkmark the Chart Control/Click OK
Put the chart control onto a form (just like any other control), size it, set it's parameters (you want bar chart, others are pie, etc). Set where it's getting it's data, and you have a bar chart.
Just use the help menu for the Chart control to see how to use it.
i thought his explanation was quite comprehensive, follow the instructions carefully
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case. Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
Controls are simply the things you see when you click the toolbox icon. You drag controls onto your form, then using their property settings, customize them.
A new project in VB6 only loads with the basic controls, such as Label, Textbox, CommandButton, Checkbox.....and so on.
There are literally dozens of other controls available and you can load them into your project and use them. To load a new control, follow the steps I gave. On your main menu, click Project. Then on the popup menu, click Components, and so on.
Here is an example of a bar chart I constructed in VB6 using several shape controls, line controls, and labels. You could come close to this using MS Chart by itself, but I decided to use a collection of other controls to draw the bars and show the numbers:
If nothing else, this Pic illustrates what the other posters are trying to tell you also. The power of VB6 is available to make nice charts, but you must learn to use the available controls and use your data values to size the controls.