Listbox response to change color of grid.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ZAresident
    New Member
    • Dec 2012
    • 4

    Listbox response to change color of grid.

    Hi, Using VB6, I need to change color of a 'Grid' I have coded under 'Declarations.

    This color change notification needs to come from a listbox on my form.

    I need to reference my 'Dim NewGridColorReq uested' to tell the grid to now be drawn in new selected color from the list box color selected.

    My Grid Code:
    Code:
    'Draw Grid
    Public Sub DrawGrid(GridSize As Single)
        Dim OldDMode As Integer, OldDSize As Integer, CX As Single, CY As Single
        Dim GridSpan As Integer
        Dim ColNumberName
        Dim GridCircleColors
        
    
        OldDMode = Document.DrawMode
        MousePointer = 11
        DoEvents
        Document.DrawMode = vbInvert
        OldDrawSize = Document.DrawWidth
        Document.DrawWidth = 1
        GridSpan = CInt(GridSize * 1440)
        CY = GridSpan
        CX = GridSpan
       ' Column = 0      ' Put to start naming/numbering my columns
        Rows = Int(Document.ScaleHeight / GridSpan)
        For Row = 1 To Int(Document.ScaleHeight / GridSpan)
        Cols = Int(Document.ScaleWidth / GridSpan)
            For Col = 1 To Int(Document.ScaleWidth / GridSpan)
                Document.PSet (CX, CY)
                CX = CX + GridSpan                                          '
                Next
              CX = GridSpan
            CY = CY + GridSpan
        Next
        Document.DrawMode = OldDMode
        Document.DrawWidth = OldDrawSize
         MousePointer = 0
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    
    
    ColsTotal = Cols
    
    
    
    DrwX = 0
    DrwY = 0
    BeepCount = 0
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    '  START Naming my GRID in loop sample
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
       NamedNumber = 0
    '   frmMDIMainPage ListCordsNamed
    
    For Outer = 0 To Cols
                DrwX = DrwX + 120
        For Inner = 0 To Rows
                 DrwY = DrwY + 120
                        Document.Circle (DrwX, DrwY), 9, RGB(255, 0, 255)
    
    
        Next Inner
        DrwY = 0
    Next Outer
    
    
       
    End Sub
    
    My List box code"
    ''''''''''''''''''''''''''''''''''''''''''''''''''''
    ''''''Grid Color '''''''''''''''''''''''''''''''''''''''''''''
    '''''''''''''''''''''''''''''''''''''''''''''''''''''
    
    Public Sub List2_Click()
    Select Case List2.Text
    Case "Black"
                Document.Cls
                    DrawGrid GridPix
                      '  frmElectronicPageChild.DrawGrid as
                     ' I named my Form1 as frmElectronicPageChild                           'NewGridColorRequested = RGB(0, 0, 0) ' This colors the circle used as the grid points
    Case "Red"
                Document.Cls
                    DrawGrid GridPix
                        GridCircleColors = RGB(255, 0, 0)
    Case "Green"
                Document.Cls
                    GridCircleColors = RGB(0, 255, 0)
                        DrawGrid GridPix
                        
    Case "Yellow"
                Document.Cls
                    DrawGrid GridPix
                        GridCircleColors = RGB(255, 255, 0)
    Case "Blue"
                Document.Cls
                    DrawGrid GridPix
                        GridCircleColors = RGB(0, 0, 255)
    Case "Magenta"
                Document.Cls
                    DrawGrid GridPix
                        GridCircleColors = RGB(255, 0, 255)
    Case "Cyan"
                Document.Cls
                    DrawGrid GridPix
                        GridCircleColors = RGB(0, 255, 255)
    
    End Select
    End Sub
    Last edited by Frinavale; Dec 5 '12, 08:12 PM. Reason: Added code tags. Please post code in code tags in the future.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    So what problem are you having? Are you getting errors? What are the error messages? Is it not doing what you want? What is it doing instead?

    Comment

    • ZAresident
      New Member
      • Dec 2012
      • 4

      #3
      The attempts I make to contact the Griddraw from my list box response are not being received by the griddraw code. My new 'specs' on color remain 'empty.

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        You need to do some basic debugging first.

        1) Make sure List2.Text is returning what you think it's returning.

        2) Make sure GridPix is set to what you think it's being set to. I'm not even sure why you're passing GridPix when you in no way vary it's value in your code.

        3) You have not defined the variable GridCircleColor s so I don't see the purpose of setting it. you don't even use it for anything.

        Comment

        • ZAresident
          New Member
          • Dec 2012
          • 4

          #5
          Rabbit, thanks for your prompt reply,sorry mine is a bit later - I am GMT +2.
          1)Will sort it, your answer showingList2.Te xt certainly helped me on the right track.
          A comment follows POINT 2 and 3 .
          2)Here I am lost, you replied, "Make sure GridPix is set to what you think it's being set to. Then you mention, "vary it's code".
          3) I will define variable, 'GridCircleColo rs'
          Comment:
          I am a serious 'Amateur' or 'Novice' at VB6.
          I have learnt such as I know from self help books only.
          I sourced the GridPix code off the 'Net to make a Grid where upon, later, I will want to make reference to the various points as needed.
          I initially wanted to put my Controls on a MDI 'Parent' Form and allow the Picbox holding the GridPix to be on the 'Child', I fell apart trying to reference across the Forms, and in my confusion,that' s probably where the errors Point 1) and 3) arose.
          Thank you for helping.

          Comment

          • Rabbit
            Recognized Expert MVP
            • Jan 2007
            • 12517

            #6
            In regards to 2, you reference a variable called GridPix. But you never set it anywhere in your code. As for the varying the code, that's not what I said. I said vary the value. Basically, you seem to be passing a value that's always going to be the same. So why pass it at all?

            In regards to 3, I have no idea what you said.

            Comment

            • ZAresident
              New Member
              • Dec 2012
              • 4

              #7
              Rabbit, Thanks for reply and help.
              My Point 2: I shall sort out GridPix. Re: reference a variable called GridPix.
              My Point 3: was confusing - sorry. I was trying to say,
              I am using a MDI Parent and Child Forms.
              A ListBox2 response from User on Parent Form should cause Grid Color to change on Grid inside a PicBox on the Child Form.
              I think the addressing is similiar to frm.MDI.(...?)
              - Should I need help after my next attempt, i will ask again, with a more detailed question.

              Comment

              Working...