Welcome Guest
Log In | Register )
You last visited January 24, 2017, 6:04 am
All times shown are
Eastern Time (GMT-5:00)

Parsing

Topic closed. 91 replies. Last post 12 years ago by Sedertree.

Page 6 of 7
PrintE-mailLink
Avatar
East Jordan, MI
United States
Member #2
June 1, 2001
675 Posts
Offline
Posted: February 13, 2005, 11:22 pm - IP Logged

Ok,



Maybe I was too tired to think about this rationally last night.



I think I have a plan to make this work. I'll create a list of strings (Picture1 to Picture100). Then dim a string variable "Picstr", and loop through the list. A crude explanation but I think you get the jist. I'll post the for..next loop if it works.



This should work....

    Avatar
    East Jordan, MI
    United States
    Member #2
    June 1, 2001
    675 Posts
    Offline
    Posted: February 14, 2005, 2:47 pm - IP Logged

    Well that didn't work....



    I have to make (n) an array variable instead. Which means that again I have to recreate the arrays and stack them. Like developer said, it's better to do it the right way while the code is still young.



    However, I did finish one array using a for...next loop to populate. Very fast this time around.

      Developer's avatar - logo2 small.jpg
      Somerset
      United Kingdom
      Member #9710
      December 17, 2004
      186 Posts
      Offline
      Posted: February 16, 2005, 5:29 pm - IP Logged

      Question What is PopBar0?

       is it a progressbar?

        Developer's avatar - logo2 small.jpg
        Somerset
        United Kingdom
        Member #9710
        December 17, 2004
        186 Posts
        Offline
        Posted: February 16, 2005, 5:54 pm - IP Logged

        Major problem with your code.

        Why Picture1(0). Picture2(0). etc

        why not

        Picture1(0). Picture1(1). Picture1(2) Picture1(3). Picture1(4) .etc

        Picture2(0). Picture2(1). Picture2(2) Picture2(3). Picture2(4) .etc

        Could make it work easy if you done it like that

        Heres a little function I made for you but I don,t think it will help

        Function PopBar(frm As Form)

            For Each Control In frm.Controls

                If TypeOf Control Is PictureBox Then
                   
                    i = i + 1
                    With Control
                    .Visible = False
                    If "Picture" & i = Control.Name Then MsgBox "yes"
                    End With
        Debug.Print Control.Name & "(" & Control.Index & ")"
                End If

            Next Control
        End Function

        It just finds all pictureboxs in a form and returns there names

          Badger's avatar - adu50016 NorthAmericanBadger.jpg
          Wisconsin
          United States
          Member #1303
          March 27, 2003
          1508 Posts
          Offline
          Posted: February 16, 2005, 8:08 pm - IP Logged
          Quote: Originally posted by Sedertree on February 13, 2005


          Thanks Badger,

          Here is another problem that popped up tonight. Procedure is too large. I don't know how I'm going to make a For..Next loop for the arrays. I'll need help from the fellow programmers for this.

          Private Sub PopBar0_Click()
                  Label3.ToolTipText = txtCount0.Text
                  'Digit "0"
                  If Val(txtCount0) = 1 Then Picture1(0).Visible = True
                  If Val(txtCount0) = 1 Then Exit Sub
                  If Val(txtCount0) = 2 Then Picture1(0).Visible = True
                  If Val(txtCount0) = 2 Then Picture2(0).Visible = True
                  If Val(txtCount0) = 2 Then Exit Sub
                  If Val(txtCount0) = 3 Then Picture1(0).Visible = True
                  If Val(txtCount0) = 3 Then Picture2(0).Visible = True
                  If Val(txtCount0) = 3 Then Picture3(0).Visible = True
                  If Val(txtCount0) = 3 Then Exit Sub
                  If Val(txtCount0) = 4 Then Picture1(0).Visible = True
                  If Val(txtCount0) = 4 Then Picture2(0).Visible = True
                  If Val(txtCount0) = 4 Then Picture3(0).Visible = True
                  If Val(txtCount0) = 4 Then Picture4(0).Visible = True
                  If Val(txtCount0) = 4 Then Exit Sub
                  If Val(txtCount0) = 5 Then Picture1(0).Visible = True
                  If Val(txtCount0) = 5 Then Picture2(0).Visible = True
                  If Val(txtCount0) = 5 Then Picture3(0).Visible = True
                  If Val(txtCount0) = 5 Then Picture4(0).Visible = True
                  If Val(txtCount0) = 5 Then Picture5(0).Visible = True
                  If Val(txtCount0) = 5 Then Exit Sub

          Trying to show up to Picture100(0)


          Wish I could help on this one for you George. When the PC first came out in the 80's, I saw its potential. Those days it was little more than the Commodore 64...for which you had to learn BASIC programming since there weren't too many software programs. SO I learned it. Then as the tech started growing exponentially, I didn't have the time to keep up. Now its kinda like my car....all I do is drive the darn thing.

          ============

          How can you tell if a politician is lying?

          Answer: His lips are moving.

            Avatar
            East Jordan, MI
            United States
            Member #2
            June 1, 2001
            675 Posts
            Offline
            Posted: February 17, 2005, 1:29 am - IP Logged
            Quote: Originally posted by Developer on February 16, 2005

            Question What is PopBar0? is it a progressbar?





            Major problem with your code.



            Why Picture1(0). Picture2(0). etc



            why not....






            Hi Jamie,



            PopBar0 is POPulate BAR graph 0.... I suppose if a progress bar could stand on two legs then that would be my array(s). Seriously tho'...



            That was my point in the last message... I dove right in on this new form and didn't look far enough ahead when creating the first arrays.



            I'm happy to report that all is well. The arrays have been fixed, which allowed me to replace those long procedures with for...next loops. Don't know how much exactly I shaved off but I'm sure it was substantial.



            This was tricky and required a nested for...next loop;



            Private Sub PopBar0_Click()

                    Label3.ToolTipText = txtCount0.Text

                    'Digit "0"

            For cnt = 1 To Val(txtCount0)

                    For cntc = 1 To 100

                    If Val(txtCount0) = cnt Then Picture0(cntc).Visible = True

                    If cnt = cntc Then Exit For

                    Next cntc

            Next cnt



            End Sub
              Avatar
              East Jordan, MI
              United States
              Member #2
              June 1, 2001
              675 Posts
              Offline
              Posted: February 17, 2005, 3:16 am - IP Logged





              Replacing the large procedures with for...next loops has cut the compiling time down to less than ten seconds vice 5 minutes.



              The only problem right now is that switching position analysis with large amounts of data with frequencies over 100. Produces a large flicker that turns part of this form white, or what I call "whiteout". Probably a computer memory issue. The minimum requirement will have to be 512mb of ram with 1gb recommended. I should probably add a timer control to give the graphics time to catch up in between procedures.

                Avatar
                East Jordan, MI
                United States
                Member #2
                June 1, 2001
                675 Posts
                Offline
                Posted: February 19, 2005, 6:20 am - IP Logged

                Anyone understand double-buffering and how to use it?



                Drawing the charts is no problem. It takes so much time to erase a (large) chart and then draw a new one that the graphics can't keep up with the code, which I think is causing the flicker. I found some info on double-buffering but don't understand how to utilize it. Here is the reset code to erase the previous arrays.



                For x = 1 To 100

                        If Val(txtCount0) = 0 Then Exit For

                        Picture0(x).Visible = False

                        If x = Val(txtCount0) Then Exit For

                Next x

                For x = 1 To 100

                        If Val(txtCount1) = 0 Then Exit For

                        Picture1(x).Visible = False

                        If x = Val(txtCount1) Then Exit For

                Next x

                For x = 1 To 100

                        If Val(txtCount2) = 0 Then Exit For

                        Picture2(x).Visible = False

                        If x = Val(txtCount2) Then Exit For

                Next x

                For x = 1 To 100

                        If Val(txtCount3) = 0 Then Exit For

                        Picture3(x).Visible = False

                        If x = Val(txtCount3) Then Exit For

                Next x

                For x = 1 To 100

                        If Val(txtCount4) = 0 Then Exit For

                        Picture4(x).Visible = False

                        If x = Val(txtCount4) Then Exit For

                Next x

                For x = 1 To 100

                        If Val(txtCount5) = 0 Then Exit For

                        Picture5(x).Visible = False

                        If x = Val(txtCount5) Then Exit For

                Next x

                For x = 1 To 100

                        If Val(txtCount6) = 0 Then Exit For

                        Picture6(x).Visible = False

                        If x = Val(txtCount6) Then Exit For

                Next x

                For x = 1 To 100

                        If Val(txtCount7) = 0 Then Exit For

                        Picture7(x).Visible = False

                        If x = Val(txtCount7) Then Exit For

                Next x

                For x = 1 To 100

                        If Val(txtCount8) = 0 Then Exit For

                        Picture8(x).Visible = False

                        If x = Val(txtCount8) Then Exit For

                Next x

                For x = 1 To 100

                        If Val(txtCount9) = 0 Then Exit For

                        Picture9(x).Visible = False

                        If x = Val(txtCount9) Then Exit For

                Next x

                I separated these so the code would run faster by exiting the for..next loop(s) as early as possible. I tried locking the forms refresh and ran 5 timer dvents to the max and it still wasn't enough time for the graphics to "catch up". The flicker only happens when analyzing over 300 draws for all positions, then analyzing a specific position. It flickers right before the new graph is displayed.

                  lottoarchitect's avatar - waveform

                  Greece
                  Member #2815
                  November 18, 2003
                  502 Posts
                  Offline
                  Posted: February 19, 2005, 7:15 am - IP Logged
                  Quote: Originally posted by Sedertree on February 19, 2005

                  Anyone understand double-buffering and how to use it?








                  This is a common technique. You use two draw buffers. Whilst the 1st one is being displayed on the screen (or a window), you draw on the 2nd buffer. When the 2nd buffer has been filled up by whatever you want, you set this buffer as the display buffer and you start drawing on the 1st buffer. When you have finished drawing on the 1st buffer again, you set this as the display buffer and you draw on the 2nd buffer and so on. It is a very effective techinque as the system always displays something correct (a complete buffer), no matter how much time might take you to draw on the other buffer. That way, you avoid drawing on the buffer when the monitor scan beam displays a particular part of the screen (which causes the so called flickering).

                  Now, in tems of code, you have to create 2 buffers and you should swap them alternatively. If you use a virtual canvas, create two intances and each time assign a canvas to the DC window (the handle). Some more restrictions apply but as I can see you can manage graphics so it will be no difficult to override them. Hope this helps.

                  If you have something to do, at least do it well...

                    Avatar
                    East Jordan, MI
                    United States
                    Member #2
                    June 1, 2001
                    675 Posts
                    Offline
                    Posted: February 19, 2005, 9:31 pm - IP Logged

                    Apagogeas,



                    I think I understand what you mean;



                    On the same form;



                    I copy each array to a spot outside the display window.



                    Then as I draw (.visible = True) one array, I (.visible = False) the copy. Then as the copy array finishes drawing or erasing, I make array1 = array2?



                    I'll try it out and see what happens. My question now is what is my trigger to make the visible array = the off screen array. If the last cell (picture) in the last array is the trigger. The boolean value will be true even though the graphic has not actually been drawn yet.



                    I just thought of this. Couldn't I just put a do...while frmGraphic.Refresh = False loop in the timer dvent?



                    Thanks,

                    ..../George

                      lottoarchitect's avatar - waveform

                      Greece
                      Member #2815
                      November 18, 2003
                      502 Posts
                      Offline
                      Posted: February 20, 2005, 2:49 am - IP Logged

                      Double buffering is essential for graphics systems, especially computer games. There, most of the time you do not know how much time will take up to draw the next image to display and thus you need to have an already correct image (the last completed) to display, as the monitor beam constantly refresh the monitor. In computer games the trigger is the vertical blank period of the scan beam (or vertical synchronization as called the last years).

                      In computer applications and operating systems, windows and so on, you do not have access to vertical blank and any low level hardware parameters. Operating systems handle (and hide) all these aspects from you. What you can do, is to have 2 canvas (where you draw anything) and within the synchronize method (assuming the drawing performed by a thread), do the swapping. Use the synchronize (any visual component drawing requires this) as windows lock their canvas during display. I haven't used double buffering in windows applications, never had to but if it has chances to work on windows, it would be that way. If you do not use a thread, then you do not gain anything using double buffering as the display does not refresh anyway until your application resumes control to the windows message system (where the command, refresh display occurs). Thus, without a thread, you draw directly on the windows canvas (in unlock mode) and when you are ready, you signal (a windows message) to refresh the display (the canvas) to be drawn on the window.

                      In more detail, each window on your screen has a canvas object associated with it. On the canvas, you can draw directly within the window, given you do any drawing when the canvas is in unlock mode. Read the help file of your visual language for more on synchronize and canvas locking. But as canvas is an object, you can initialise as many as you like and thus you can perform double buffering by swapping those canvas.

                      The .visible you mention refers to the window property; this should be always visible. What you modify is the canvas of the window.

                      If you have something to do, at least do it well...

                        Avatar
                        East Jordan, MI
                        United States
                        Member #2
                        June 1, 2001
                        675 Posts
                        Offline
                        Posted: February 20, 2005, 5:49 am - IP Logged

                        Apagogeas,



                        I think I have solved this problem.



                        I poked around in MSDN and came across a section entitled "Lightweight Graphical Controls". It seems to advocate using the Shape Control in place of the PictureBox Control for what I need to do.



                        Replacing the picturebox arrays with shape arrays; I should be able to speed things up.



                        Sounds like a winner....

                          Avatar
                          East Jordan, MI
                          United States
                          Member #2
                          June 1, 2001
                          675 Posts
                          Offline
                          Posted: February 21, 2005, 6:09 am - IP Logged

                          OMG!!!



                          I thought this would be faster.... But I had no idea it would be that fast.



                          The distribution chart analyzed, and displayed, the frequencies for all positions (2000 draws) in less than two seconds. No flicker whatsoever when switching positions.



                          This is awesome!!!

                            Avatar
                            East Jordan, MI
                            United States
                            Member #2
                            June 1, 2001
                            675 Posts
                            Offline
                            Posted: February 21, 2005, 1:12 pm - IP Logged

                            Oh, almost forgot.....



                            Don't try the "do...while form.Refresh = False" loop. It returns an unexpected value error in runtime. I'm sure there is some API call or something similiar that would determine when the screen refreshes.



                            Don't really need to know how to do it myself at this point though.



                            A few additions to the chart code (top secret stuff). Then I can get back to work on more pressing matters.

                              Developer's avatar - logo2 small.jpg
                              Somerset
                              United Kingdom
                              Member #9710
                              December 17, 2004
                              186 Posts
                              Offline
                              Posted: February 25, 2005, 8:51 am - IP Logged

                              Sedertree, Sorry I have not posted for a while, been updating my own software.

                               

                              Sounds like you are geting on top of things now, I know Pictureboxes use loads of memory, but they make good control holders where as an image control can not.

                              Just wanted to show of what I have been doing

                              What you think

                              Also see results for any month in any or every year 

                              Got to put the month names in yet but you can see the closest is Jan the one at the back is Dec