# VBForums CodeBank > CodeBank - Visual Basic 6 and earlier >  Simple, but functional and VERY effective graph control

## Wokawidget

I have written a small compact graph usercontrol control.

Features:
Squigillians of pointsDraw Line GraphDraw Bar GraphAll Custom ColorsDraw PointsDraw AxisFixed ItemsSave ALL grid and point properties to a fileLoad a graph from a saved file
I think that's it.
With the graph it's possible to do the following:
Draw a moving graph, like you see in task managerDraw a histogram, bar and line graphsDraw mathematical equations, like Sin Wave or x^2Draw a moving music graphic equaliser thingy like in media playerCreate a progress bar
It's something I knocked up in the last 24hrs. I can't find any bugs, but I am sure one of the little bastards is still lurking around  :Big Grin: 

Any comments or suggestions would be great.

Cheers.

Woka

----------


## Wokawidget

OK. Here's Version 2.0 of the control.
It can now handle multiple datasets  :Big Grin: 

This allows you to add even more functionality...check out the music equalizer demo  :Smilie: 

This demo show's you most of the styles and functionality you can do with this control, except the Loading and Saving of the graph.
I will write a form and add it into the demo to do this.

Wooooof

----------


## Wokawidget

There are a few little bugs left, but they are hard to replicate  :Frown: 
I will clear them up soon.

One thing it doesn't do, is multiple datasets in bar mode. This is because the last dataset drawn overwrites the previous bars from the other datasets.
Not sure how to do this yet...maybe offset them or something. Hnmmmmmm

Woiof

----------


## Yeahdisk

Wow!  Thanks a lot!

One slight problem, when I try to open your sample programme so I can try and understand how it works, i Get the following errors:
"Line 13: Class vbGraph.Graph of control Graph1 was not a loaded control class." for each .frm

I guess this is me being inadequate in using VB, could someone possibly tell me what I need to do? I tried to install VBGraph as a component, but that didn't seem to work.

Cheers, Chris.

PS - Here is the VB Code I have for my application, does it seem straightforward to get the information that I am currently writing into the textboxes, to be reperesented in this chart? 

Private Sub Timer1_Timer()
Dim buffer() As Byte
'define buffer to use for the data
'in this configuration you can only send 8 bytes at a time

ReDim buffer(8)

'write to PIC
HIDComm1.WriteTo buffer(), 8

'read data back from the PIC
buffer() = HIDComm1.ReadFrom(8)

'put result from AN0 channel into first text box Its the 8 bits in each of 
'these buffers that I want to Chart in RealTime
Text1.Text = buffer(1)

'put result from AN1 channel into second text box
Text2.Text = buffer(2)

'put result from AN2 channel into third text box
Text3.Text = buffer(3)

'put result from AN4 channel into fourth text box
Text4.Text = buffer(4)

'put result from AN5 channel into fifth text box
Text5.Text = buffer(5)

'put result from AN6 channel into sixth text box
Text6.Text = buffer(6)

'put result from AN7 channel into seventh text box
Text7.Text = buffer(7)

End Sub


Private Sub Form_Load()
'connect to the USB device as the program starts
 HIDComm1.Connect

End Sub

Private Sub Form_Terminate()
'disconnect from the USB device as prgoram ends
'THIS IS IMPORTANT
 HIDComm1.Uninit

End Sub

Private Sub HIDComm1_ConnectSuccess(ByVal Status As Long)

 Caption = "Huzzah! - Its Connected"

End Sub

Private Sub HIDComm1_Disconnected(ByVal Status As Long)

 Caption = "Not Connected"

End Sub

Private Sub Timer2_Timer()
'try and reconnect the PIC
  If HIDComm1.Connected = False Then
    HIDComm1.Connect
  End If

End Sub

----------


## CVMichael

Hi Wokawidget,

I did not look at your usercontrol, but reading about it, I got an idea.
In this thread http://www.vbforums.com/showthread.php?t=328242 , I did some reserch on fixing the distorted sound, and i got the solution with the trend thing, I tought you can use the same thing to draw graphs...

Anyways, I wrote some code to see what I mean, put a picturebox on the form, and paste the following code to see it in action.

The only functions I wrote are: DrawTrend, ExpandPoints, ExpandPointsB, and how to use them in Form_Load.

Maybe you can incorporate this in your graphing usercontrol...

VB Code:
Option Explicit
 Private Type POINT
    X As Double
    Y As Double
End Type
 Private Sub Form_Load()
    Dim SinglePoints(4) As Double, InTrendPoints() As POINT, OutTrendPoints() As POINT
    
    SinglePoints(0) = 10
    SinglePoints(1) = 35
    SinglePoints(2) = 50
    SinglePoints(3) = 18
    SinglePoints(4) = 13
    
    ' increase the "ExpandTo" param to have even more precision
    InTrendPoints = ExpandPoints(SinglePoints, 60)
    'InTrendPoints = ExpandPointsB(SinglePoints, 60) ' a simpler expand...
    OutTrendPoints = Trend(InTrendPoints, 3)
    
    Picture1.AutoRedraw = True
    DrawTrend Picture1, InTrendPoints, RGB(180, 180, 180)
    DrawTrend Picture1, OutTrendPoints, vbBlue
End Sub
 Private Sub DrawTrend(Pic As PictureBox, Points() As POINT, ByVal Color As Long, Optional WithPoints As Boolean = False)
    Dim MaxY As Double, MaxX As Double, K As Long, EmptySpaceX As Double, EmptySpaceY As Double
    
    For K = 0 To UBound(Points)
        If Points(K).X > MaxX Then MaxX = Points(K).X
        If Points(K).Y > MaxY Then MaxY = Points(K).Y
    Next K
    
    EmptySpaceX = MaxX * 0.1
    EmptySpaceY = MaxY * 0.1
    
    Pic.Scale (-EmptySpaceX, MaxY + EmptySpaceY)-(MaxX + EmptySpaceX, -EmptySpaceY)
    Picture1.DrawWidth = 1
    
    Pic.Line (-EmptySpaceX, 0)-(MaxX + EmptySpaceX, 0), RGB(128, 128, 128)
    Pic.Line (0, MaxY + EmptySpaceY)-(0, -EmptySpaceY), RGB(128, 128, 128)
    
    Picture1.DrawWidth = 2
    Pic.PSet (Points(0).X, Points(0).Y), Color
    
    If WithPoints Then
        For K = 1 To UBound(Points)
            Pic.PSet (Points(K).X, Points(K).Y), Color
        Next K
    Else
        For K = 1 To UBound(Points)
            Pic.Line -(Points(K).X, Points(K).Y), Color
        Next K
    End If
End Sub
 Private Function ExpandPointsB(InPoints() As Double, ExpandTo As Long) As POINT()
    Dim OutPoints() As POINT, K As Long, Per As Double, X As Long
    
    If ExpandTo <= 2 Then Exit Function
    ReDim OutPoints(ExpandTo - 1)
    
    For K = 0 To UBound(OutPoints)
        Per = K / CDbl(UBound(OutPoints))
        X = Round(UBound(InPoints) * Per)
        
        OutPoints(K).X = K + 1
        OutPoints(K).Y = InPoints(X)
    Next K
    
    ExpandPointsB = OutPoints
End Function
 Private Function ExpandPoints(InPoints() As Double, ExpandTo As Long) As POINT()
    Dim OutPoints() As POINT, K As Long, Per As Double, PerX As Double, LngX As Long
    
    If ExpandTo <= 2 Then Exit Function
    ReDim OutPoints(ExpandTo - 1)
    
    For K = 0 To UBound(OutPoints) - 1
        Per = K / CDbl(UBound(OutPoints))
        
        PerX = UBound(InPoints) * Per
        LngX = Fix(PerX)
        
        OutPoints(K).X = K + 1
        OutPoints(K).Y = InPoints(LngX) + (InPoints(LngX + 1) - InPoints(LngX)) * (PerX - LngX)
    Next K
    
    OutPoints(K).X = K + 1
    OutPoints(K).Y = InPoints(UBound(InPoints))
    
    ExpandPoints = OutPoints
End Function
 Private Function Trend(Data() As POINT, ByVal Degree As Long) As POINT()
    'degree 1 = straight line y=a+bx
    'degree n = polynomials!!
    
    Dim a() As Double
    Dim Ai() As Double
    Dim b() As Double
    Dim P() As Double
    Dim SigmaA() As Double
    Dim SigmaP() As Double
    Dim PointCount As Long
    Dim MaxTerm As Long
    Dim m As Long, n As Long
    Dim i As Long, J As Long
    Dim Ret() As POINT
    
    Degree = Degree + 1
    
    MaxTerm = (2 * (Degree - 1))
    PointCount = UBound(Data) + 1
    
    ReDim SigmaA(MaxTerm - 1)
    ReDim SigmaP(MaxTerm - 1)
    
    ' Get the coefficients lists for matrices A, and P
    For m = 0 To (MaxTerm - 1)
        For n = 0 To (PointCount - 1)
            SigmaA(m) = SigmaA(m) + (Data(n).X ^ (m + 1))
            SigmaP(m) = SigmaP(m) + ((Data(n).X ^ m) * Data(n).Y)
        Next
    Next
    
    ' Create Matrix A, and fill in the coefficients
    ReDim a(Degree - 1, Degree - 1)
    For i = 0 To (Degree - 1)
        For J = 0 To (Degree - 1)
            If i = 0 And J = 0 Then
                a(i, J) = PointCount
            Else
               a(i, J) = SigmaA((i + J) - 1)
            End If
        Next
    Next
    
    ' Create Matrix P, and fill in the coefficients
    ReDim P(Degree - 1, 0)
    For i = 0 To (Degree - 1)
        P(i, 0) = SigmaP(i)
    Next
    
    ' We have A, and P of AB=P, so we can solve B because B=AiP
    Ai = MxInverse(a)
    b = MxMultiplyCV(Ai, P)
    
    ' Now we solve the equations and generate the list of points
    PointCount = PointCount - 1
    ReDim Ret(PointCount)
    
    ' Work out non exponential first term
    For i = 0 To PointCount
        Ret(i).X = Data(i).X
        Ret(i).Y = b(0, 0)
    Next
    
    ' Work out other exponential terms including exp 1
    For i = 0 To PointCount
        For J = 1 To Degree - 1
            Ret(i).Y = Ret(i).Y + (b(J, 0) * Ret(i).X ^ J)
        Next
    Next
    
    Trend = Ret
End Function
 Private Function MxMultiplyCV(Matrix1() As Double, ColumnVector() As Double) As Double()
    Dim i As Long
    Dim J As Long
    Dim Rows As Long
    Dim Cols As Long
    Dim Ret() As Double
    
    Rows = UBound(Matrix1, 1)
    Cols = UBound(Matrix1, 2)
    
    ReDim Ret(UBound(ColumnVector, 1), 0) 'returns a column vector
    
    For i = 0 To Rows
        For J = 0 To Cols
            Ret(i, 0) = Ret(i, 0) + (Matrix1(i, J) * ColumnVector(J, 0))
        Next
    Next
    
    MxMultiplyCV = Ret
End Function
 Private Function MxInverse(Matrix() As Double) As Double()
    Dim i As Long
    Dim J As Long
    Dim Rows As Long
    Dim Cols As Long
    Dim Tmp() As Double
    Dim Ret() As Double
    Dim Degree As Long
    
    Tmp = Matrix
    
    Rows = UBound(Tmp, 1)
    Cols = UBound(Tmp, 2)
    Degree = Cols + 1
    
    'Augment Identity matrix onto matrix M to get [M|I]
    ReDim Preserve Tmp(Rows, (Degree * 2) - 1)
    For i = Degree To (Degree * 2) - 1
        Tmp(i Mod Degree, i) = 1
    Next
    
    ' Now find the inverse using Gauss-Jordan Elimination which should get us [I|A-1]
    MxGaussJordan Tmp
    
    ' Copy the inverse (A-1) part to array to return
    ReDim Ret(Rows, Cols)
    For i = 0 To Rows
        For J = Degree To (Degree * 2) - 1
            Ret(i, J - Degree) = Tmp(i, J)
        Next
    Next
    
    MxInverse = Ret
End Function
 Private Sub MxGaussJordan(Matrix() As Double)
    Dim Rows As Long
    Dim Cols As Long
    Dim P As Long
    Dim i As Long
    Dim J As Long
    Dim m As Double
    Dim d As Double
    Dim Pivot As Double
    
    Rows = UBound(Matrix, 1)
    Cols = UBound(Matrix, 2)
     ' Reduce so we get the leading diagonal
    For P = 0 To Rows
        Pivot = Matrix(P, P)
        
        For i = 0 To Rows
            If Not P = i Then
                m = Matrix(i, P) / Pivot
                
                For J = 0 To Cols
                    Matrix(i, J) = Matrix(i, J) + (Matrix(P, J) * -m)
                Next
            End If
        Next
    Next
    
    'Divide through to get the identity matrix
    'Note: the identity matrix may have very small values (close to zero)
    'because of the way floating points are stored.
    For i = 0 To Rows
        d = Matrix(i, i)
        
        For J = 0 To Cols
            Matrix(i, J) = Matrix(i, J) / d
        Next
    Next
End Sub

----------


## Wokawidget

Very nice code indeed!  :Thumb: 

Should be quite easy to add in.
All that should be need, at 1st glance, if a function to take the data from one dataset, and pass it through those functions above, and return another dataset with many many point (so it looks like a curve).

Woka

----------


## rookie7799

> OK. Here's Version 2.0 of the control.
> It can now handle multiple datasets 
> 
> This allows you to add even more functionality...check out the music equalizer demo 
> 
> This demo show's you most of the styles and functionality you can do with this control, except the Loading and Saving of the graph.
> I will write a form and add it into the demo to do this.
> 
> Wooooof


This is one great program! Thanks a lot for sharing it.
I have couple of questions tho  :Smilie: 

1. Is it possible to add Hscroll to line graph, so that if we have about 10000 points to put on the graph we can, lets say see only 100 of them on the picture and then when scrolling see the others. Sort of like real time graph but old point don't disapear they stay there and can be seen if scrolled back.

2. Zoom in, zoom out   :Wink:  Maybe?

3. A small tutorial on how to do this of course not the whole thing just to have a idea...

4. Make the graph interactive. show the points, label them when mouse point on one it will show it's coordinates

5. Just kidding   :big yellow:  that's a lot to ask already. 

GREAT JOB MAN   :Thumb:

----------


## c0d3r

Hello Woka  :Embarrassment: )   :wave:  

Firstly .. its a gr8 program that u have written and it is really helpfull for n00bs like me  :Smilie:  . But as i am still a n00b   :big yellow:  , i am having some problems with using vbgraph. I made an ocx from the vb project u posted, and included in my project. Now, all the settings are understandable but i have no clue as to how to pass on the data to be graphed ?? i cud'nt see no variables or arrays or anything of the sort .... and there was nothing on the post  :Frown:   . Im using it to make a PC based Oscilloscope ( or atleast planning to use vbgraph for plotting data) coz i cud'nt find any other method to plot data in realtime ......( any suggestions will be greatly appreciated  :Embarrassment: )
Also, can data values below zero be plotted on the graph ?? If so how ??

Thanx a lot .... Hope'ing for a speedy response

<< c0d3r >>

----------


## Wokawidget

Thanks  :Big Grin: 

If you open the demo project and look at the code in the forms...frmMusic, frmBars etc.
You will see the code that adds the data to the graph. It's very simple.

Woof

PS, and yes, it does plot -ve values.

----------


## cackle61

I just stumbled on your code and it looks like just what I need. Having read through the thread, I notice you haven't answered a couple of questions which are particularly relevant to me:

1) "Yeahdisk" writes: "One slight problem, when I try to open your sample programme so I can try and understand how it works, i Get the following errors:
"Line 13: Class vbGraph.Graph of control Graph1 was not a loaded control class." for each .frm"

I get this too. How do I overcome it and more importantly, how do I access the control in my own projects?  :Confused:  

2) Rookie7799 writes: "Is it possible to add Hscroll to line graph, so that if we have about 10000 points to put on the graph we can, lets say see only 100 of them on the picture and then when scrolling see the others. Sort of like real time graph but old point don't disapear they stay there and can be seen if scrolled back."

this is just what I need.

TIA

Cheers  :Wink:

----------


## Wokawidget

:Big Grin: 

1) Are you opening the solution file or the project file?

2) Yes it is perfectly possible...if you want to write it. I don't do VB6 anymore I am afraid.

Woka

----------


## cackle61

1) the project file. I did also try one with the file extension .vbg - is that the solution file?

how do I access the control in other projects?

2) I could give it a crack - any hints on how (I'm still a novice)? I've noticed that you used a picture box as the basis of the graph, but this doesn't include scroll bars in its properties.

Thanks

----------


## Wokawidget

1) Yea, open vbg. Compile the vbGraph project then add the OCX to your other project.

2) Nope. It certainly won't be easy  :Frown: 

Woka

----------


## sukhdev.v

gr8 control!!!

----------


## sukhdev.v

Hi WokaWidget, It a Gr8 Control, But will be Better if you can post a sample project showing how to show DATA from a Database, on to the GRAPH!!!

Thanks for this wonderful control, Keep it up.   :Big Grin:

----------


## Wokawidget

Thanks  :Smilie: 

Well getting data from a DB and my graph control are 2 completely different things.
All you need to do is use code similar to what is found here: http://www.vbforums.com/showthread.p...t=vb6+database  and then add that to my code demo for the graph, and instead of adding data to the graph from a static function, you call your new function that loads data from a DB. 

Make sense?

Woka

----------


## sukhdev.v

Thank You WokaWidget, for the help and all the info!!!

----------


## navaho

Hi, I'm having trouble using the graph control.
I compiled the vbGraph.vbp to an .ocx control object and added it to my project as a component. Now I get an error when I want to use the Dataset type to set up datasets. It says that user-defined type is not defined ??? What should I do differently?

-e- my bad, I was using the older vbGraph build, which didn't have datasets defined.

----------


## Wokawidget

What line of code is giving you the error?

----------


## navaho

No errors anymore, I had the wrong vbGraph version, the one which didn't have datasets in it  :Smilie:

----------


## Wokawidget

lol  :Big Grin:  glad it's working now.

WOka

----------


## Thornsten

Hey Wokawidget, the graph works great.  Is there any way to get it to show values along the axes?  Or a key for what color line is what?

Thanks!

----------


## Wokawidget

Nope, and nope. Glad you like it.
This wasn't supposed to replace the MSChart control.
It was merely to create quick little graphs like in Task Manager and the Media Player equalizer control.

Woka

----------


## Thornsten

Haha, I didn't even know there was an MSChart control.  I'm a java developer by trade but I needed a quick app that could easily make Windows API calls so I gave VB a shot.  I'll look into the MSChart control, hope it's as easy to use as your graph control!

----------


## sam_899

Very nice control and so easy to use.

Has anyone managed to get the graphs to show the values along the axis yet?

I've been trying all day with no luck  :Frown: 

If not, could someone lead me in the right direction please?

Thanks

----------


## MatrixGTI

Very nice Work Woka !  :Smilie: 

One question... how I can save the dataset of a graph ? In a .CSV file for example ?

Thanks in advanced !

----------


## Wokawidget

Thanks  :Big Grin: 

There is no native way to export the data from the datasets.
You would have to wraite code that did that for you by looping through the datasets, then looping through the points in the dataset and outputting them to a string, and then write the string to a file.
the psuedo code would be:


```
For Each DataSet in DataSets
    Define String csvLine
    For Each point in dataSet.Points
      csvLine += "," + point.value
    Next
    Write csv line string to txt file
Next
```

I dont have the VB6 graph code in front of me I am afraid and it's been a good 4 years since I looked at it  :Frown: 

Woka

----------


## MatrixGTI

Dont worry Woka !
I suppose that the quick way is collect the data before sending them to the graph and save them to an incremental  .csv file.

Something like this



```

If FlagWriteCSV = True Then

k = CStr(kn) & Chr(9) & CStr(ActSpeed) & Chr(9) & CStr(brakeramp) & Chr(9) & CStr(SpinRamp) & Chr(9) & CStr(ActVMot / 10) & Chr(9) & CStr(ActCurrMot / 10) & Chr(9) & CStr(ActVbus / 10) & Chr(9) & CStr(temperature / 10) & Chr(9) & CStr(Round((PWMrif / 32768) * 100, 0)) & Chr(9) & Date & Chr(9) & Time & Chr(9) & CStr(STATUS.Caption) & Chr(9) & CStr(errorcount) & Chr(9) & CStr(Text1(440).Text) & Chr(9) & CStr(Text1(441).Text) & Chr(9) & CStr(Text1(442).Text) & Chr(9) & CStr(Text1(443).Text)

Print #1, k

kn = kn + 1

Label17.Caption = "Logging:" & " " & k

startlogging.BackColor = vbGreen

Else

stoplogging.BackColor = vbRed

End If
```

----------


## Glenvn

Dear Wokawidget,

Thank you for your code! :Smilie:  Its just what I am looking for!

I am trying to use your line graph but I am struggling...

The data source is a listbox - list2 (There are 47 numeric entries)

How do I make the graph use these entries?( without scrolling function)

I have this so far:


  Code:
Private Sub SetupDatasets()
 Dim objDataset As Dataset
Dim list As Integer
       Set objDataset = Graph1.Datasets.Add
    With objDataset
        .Visible = False
        .ShowPoints = True
        .ShowLines = True
        .ShowBars = False
        .ShowCaps = False
        .LineColor = RGB(0, 0, 255)
        .PointColor = RGB(150, 150, 255)
    End With
     
   
    For i = 0 To List2.ListCount
     list = List2.list(i)
        Next i
 
  list = objDataset
  
   
  
Set objDataset = Graph1.Datasets.Add
      With objDataset
         
        .Visible = False
        .ShowPoints = True
        .ShowLines = True
        .ShowBars = False
        .ShowCaps = False
        .LineColor = RGB(0, 0, 255)
        .PointColor = RGB(150, 150, 255)
    End With
      
    
End Sub

I know this is old but it is still good code and it gets the job done! :Thumb: 

Any help would be appreciated!

----------


## si_the_geek

Welcome to VBForums  :wave: 

Based on the example project given (but no testing), I think this is what you want:


```
    For i = 0 To List2.ListCount
      objDataset.Points.Add CInt(List2.list(i))
    Next i
```

----------


## Glenvn

Hi si_the_geek!!

Thanks a million!

This works for me!! :Big Grin: 

Now I can tweak it some more! :Smilie:

----------


## Wokawidget

Hi,

Si, thanks for picking this up for me.
Sorry I didn't get back to you personally, but it seems Si took care of your question  :Smilie: 

All points need to be added to the Dataset.Points class, as shown above.
The graph can handle multiple datasets, and thus plot more than one set of data onto the graph.

Cheers,

Woka

----------


## FSandlewould

> Hi, I'm having trouble using the graph control.
> I compiled the vbGraph.vbp to an .ocx control object and added it to my project as a component. Now I get an error when I want to use the Dataset type to set up datasets. It says that user-defined type is not defined ??? What should I do differently?
> 
> -e- my bad, I was using the older vbGraph build, which didn't have datasets defined.


....I had the same problem except could not resolve it.  I could only find 2 entries of vbGraph.zip listed here and I made sure to use the most recent.  Still getting 

"Can't find project or library" 

and the highlighted line is  Dim objDataset  As Dataset

----------


## cristey

hi! I am new in using vb and i am currently making a project in vb6. my project is suppose to function like this: from a remote sensor, temperature samples will be gathered and transfer the data into computer via SMS. In the computer the interfaced used is VB6, I have been able to save the data into the flex grid, the next thing I should do is to plot it in real time basis.
-that was a big prob, cause this is my first time in vb and i locked so much of idea about this. please help me here. thanks a lot.

----------


## Wokawidget

Looks at the sample code project. This has a demo of plotting real time data.

Woka

----------


## cristey

Hi Woka,
Thanks, finally someone has noticed my post, if you don't mind, where can I find that sample codes? I have downloaded a sample code that you have posted entitled vbgraph, but I can't make it work. when I am trying to run the program, it always has an error : method or data member not found, then the .Redraw has been highlighted. thanks.

Tin..

----------


## Wokawidget

Hi..can you post a screen shot of the error?
The sample program should work....does work.

WOka

----------


## cristey

hi,
how could I attached the file? i mean the screen shot for error msg? i am sorry i am really new here and this is my first time to join a forum, what actually am i doing is i run the program, i was thinking if it requires additional api or what? really sorry, im struggling here, thanks for your help


Additional, Hi, I want to also ask about this equation,  

             If lngIndex = 3 Then
                lngValue = 70 + (Rnd * 10) - 5
            ElseIf lngIndex = 2 Then
                lngValue = 50 + (Rnd * 50) - 25
            Else

I dont understand what's happening here, why should lngValue is changed. Thanks.

----------


## Wokawidget

That is my code to get it to produce random graph data using random numbers.
I probably made it more complex than needed.
To post a screen shot click on the Go Advanced button at the bottom of this thread while logged in. Then you see a button to attach files.

Woka

----------


## cristey

hi Woka,

i really like your program, i have download the codes again ad surprised that it worked fine. Thanks so much that would be a big help to my project. thanks a lot ad i hope that you will be able to make more interesting topics.

Thanks big time!
Tin. . . .  :Wink:

----------


## Wokawidget

Np.  :Smilie: 
If you have any further questions then don't hesitate to post.

thanks.

woka

----------


## cristey

thanks, you're so cool.
uhm, hey, i got new question, I'm a little lost here in my code, I am about to separate the message I will receive from the GSM modem,My code is very simple but my prob is I don't know how to separate the next line. Here is my code:

Private Sub MSComm1_OnComm()
Static CEvent As String
Dim CChar As String * 1


Select Case MSComm1.CommEvent

    Case comEvReceive

        Do
            CChar = MSComm1.Input
            If Message_Store Then
                Message_Buffer = Message_Buffer & CChar
            End If
            Select Case CChar
                Case ">"
                     Greater_Sign = True
                     List1.AddItem CChar
                Case vbLf

                Case vbCr
                    If Len(CEvent) > 0 Then
                      Handle_Rec_Event CEvent
                      CEvent = ""
                    End If
                Case Else
                    CEvent = CEvent + CChar
            End Select

        Loop While MSComm1.InBufferCount
End Select

End Sub

Public Function Parse_SMS() As Boolean
Dim StartPoint As Long
Dim EndPoint As Long
Dim Buffer1 As String
Dim Buffer2 As String
Buffer1 = Message_Buffer
StartPoint = InStr(1, Buffer1, "+CMGR:", vbTextCompare)
EndPoint = InStr(1, Buffer1, vbCrLf & "OK", vbTextCompare)
If StartPoint <> 0 And EndPoint > StartPoint Then
   I = StartPoint
   While I < EndPoint
    Buffer2 = Buffer2 & Mid(Buffer1, I, 1)
    I = I + 1
   Wend
   Parse_SMS = True
   Message_Buffer = Buffer2
   Exit Function
End If
Parse_SMS = False
End Function


Private Sub Read_Message()
If Parse_SMS Then
   SMS_Break = Split(Message_Buffer, vbCrLf, , vbTextCompare)
   SMS_Header = Split(SMS_Break(0), ",", , vbTextCompare)
   SMS_TelNumber = Mid(Right(SMS_Header(1), 11), 1, 10)
   SMS_ID = Mid(Right(SMS_Header(2), 11), 1, 10)
    SMS_Date = Mid(Right(SMS_Header(3), 11), 2, 8)
    SMS_Date_yy = Mid(Right(SMS_Header(3), 11), 2, 2)
    SMS_Date_mm = Mid(Right(SMS_Header(3), 11), 5, 2)
    SMS_Date_dd = Mid(Right(SMS_Header(3), 11), 8, 2)
    SMS_Date = Mid(Right(SMS_Header(3), 11), 2, 8)
    SMS_Date = Mid(Right(SMS_Header(3), 11), 2, 8)
    SMS_Time = Mid(Right(SMS_Header(4), 12), 1, 8)
    SMS_Time_hh = Mid(Right(SMS_Header(4), 12), 1, 2)
    SMS_Time_mm = Mid(Right(SMS_Header(4), 12), 4, 2)
    SMS_Time_ss = Mid(Right(SMS_Header(4), 12), 7, 2)
    SMS_GMT = Mid(Right(SMS_Header(4), 12), 10, 2)
I'm not sure about this one.Ca you help me again please? thanks a lot!
  Message_Buffer = ""
   For I = 1 To UBound(SMS_Break(), 1)
       Message_Buffer = Message_Buffer & SMS_Break(I)
   Next I
    SMS_Break2 = Split(Message_Buffer, vbCrLf, , vbTextCompare)
   SMS_Header2 = Split(SMS_Break(0), ",", , vbTextCompare)
   SMS_Temp1 = Mid(Right(SMS_Header2(1), 11), 1, 10)
   SMS_Temp2 = Mid(Right(SMS_Header2(1), 11), 1, 10)
   SMS_Temp3 = Mid(Right(SMS_Header2(1), 11), 1, 10)
   SMS_Temp4 = Mid(Right(SMS_Header2(1), 11), 1, 10)

   SMS_Message = Message_Buffer
   lblErrors.Caption = "Decoding"
Else
   lblErrors.Caption = "Unable to decode Message"
End If
End Sub

----------


## Wokawidget

You may want ton post that into the VB6 forum section. 
More people will be able to see it.
I have no idea what that code does as I have never dealt with modem messages...but others may have.

woka

----------


## erupter

Hello.
I'm just looking for some kind of graph (better to say plot) control, but i'd like to stick with .net and newer.
Any chance of a control like this being available for new versions?

----------


## RobertSteele

> OK. Here's Version 2.0 of the control.
> It can now handle multiple datasets 
> 
> This allows you to add even more functionality...check out the music equalizer demo 
> 
> This demo show's you most of the styles and functionality you can do with this control, except the Loading and Saving of the graph.
> I will write a form and add it into the demo to do this.
> 
> Wooooof


need some help in programing for a client. can you assist?

thanks

:O)

----------


## id_ruben

need help, How to add text to graph ?

----------


## AlexNu

First off, thank you Wokawidget for making a really neat, simple control.

Secondly, I'd like to ask it if ok to use this control (possibly modified somewhat) in a commercial project. The project is already existing and is a bespoke tool for operating scientific equipment, and would be an improvement on the current graphing methods we used. If you've got any more questions, feel free to come back with them - it should be possible to email me.

----------


## mohammad94

Hi dear Woka

I have a few question about this project
Can I help me??
please please please

send an e-mail to me, please

I am waiting for your mail

Thanks a lot

----------


## si_the_geek

Welcome to VBForums  :wave: 

I'm afraid Woka isn't active any more...  but lots of people here could help with your questions (arguably better than Woka could, as he probably doesn't use VB6 any more).

Either post your questions as a reply here, or create a thread in our VB6 forum:  http://www.vbforums.com/forumdisplay...-6-and-Earlier

----------

