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 NewGridColorRequested' to tell the grid to now be drawn in new selected color from the list box color selected.
My Grid 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
6 2091
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?
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.
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 GridCircleColors so I don't see the purpose of setting it. you don't even use it for anything.
Rabbit, thanks for your prompt reply,sorry mine is a bit later - I am GMT +2.
1)Will sort it, your answer showingList2.Text 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, 'GridCircleColors'
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.
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.
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.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Sugapablo |
last post by:
Can anyone help me out with some code to change three table cells
(<td>) when one is hovered over?
I have a calendar grid where each day is made up of three table cells and
I want all three to...
|
by: Robbo |
last post by:
Hello, I created a datagrid with a few hyperlink columns.. How do i change
the color of the hyperlink itself? BLUE is a bit bad on my datagrid
color scheme.
Thanks,
Rob
|
by: HS1 |
last post by:
Hello all
Do you know how to change color of a button when the mouse is over it (like
a button in manu bar can change its color in a website) in VB.net
Thank you
S.Hoa
|
by: Mamatha |
last post by:
Hi
I want to change the color of icon,How it can be opened?
and how can i change color.
If any one knows please let me know
Thanks in advance.
Mamatha
|
by: Vd |
last post by:
How do I change color of the tab. I have changed the
color, but when I run the application the color is still
using the original color which is the control color.
|
by: TonyVal - MSDN News |
last post by:
Hi All,
Anyone know how to change color for a 3D button like this button control
does?
http://www.econtechvn.com/en/aquabutton_detail.htm
I see it is really cool. But, don't know how to do...
|
by: Serdge Kooleman |
last post by:
Winform (DataGrid)
when i'm editing the text in the curent cell, i need to change
color/font/background in it.
thank you
|
by: sr |
last post by:
please help
i have problem:
I know how to change color row in table when my mouse is over on this row
and change color to another color when my mouse is out from this row.
but i dont know how to...
|
by: nma |
last post by:
Hi
How do I make the cell change color to 'black' after I click on it. The cell will remain black color until I click another cell which will also change to black. I can do the mouseover and...
|
by: prabhuaradhan |
last post by:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |