Hello,
I am trying to migrate a vb6 app to vb.net. In one piece
of the vb6 app I have a label where the label backcolor
changes every 5 seconds on a timer. So I created an array
of colors as follows and then run the array in the timer
event in vb6. Not working in vb.net. How would I do this
in vb.net?
vb6 code:
-----------------------------------------
Const ORANGISH As Long = &HC0C0FF
Const ORYEL As Long = &HC0E0FF
Const YELLOWISH As Long = &HC0FFFF
Const GREENISH As Long = &HC0FFC0
Const LIGHTBLUISH As Long = &HFFFFC0
Const PURPLISH As Long = &HFFC0C0
Const PINKISH As Long = &HFFC0FF
Const WHITE As Long = &HFFFFFF
Dim arrColors As Variant
Private Sub Form_Load()
arrColors = Array(ORANGISH, ORYEL, YELLOWISH, LIGHTBLUISH,
PURPLISH, PINKISH, WHITE)
End Sub
Private Sub Timer1_Timer()
Static i
lblRunning.BackColor = arrColors(i)
i = i + 1
If i > 5 Then i = 0
End Sub
------------------------------------------------------
Here is my vb.net conversion
-----------------------------------------
constants...
Dim arrColors() As Long = {ORANGISH, ORYEL, YELLOWISH,
GREENISH, LIGHTBLUISH, PURPLISH, PINKISH, WHITE}
Private Sub Timer1_Tick(...) Handles Timer1.Tick
Static i As Integer
lblRunning.BackColor = CType(arrColors(i),
System.Drawing.Color)
i += 1
End Sub
-------------------------------------------------
The error message for vb.net says that it cannot convert a
long (arrColors(i)) to System.Drawing.Color. So how could
I achieve the same functionality in the vb.net app as in
the vb6 app above?
Thanks 5 7323
See the ColorTranslator.FromHTML method.
"B" <an*******@discussions.microsoft.com> wrote in message
news:1b****************************@phx.gbl... Hello,
I am trying to migrate a vb6 app to vb.net. In one piece of the vb6 app I have a label where the label backcolor changes every 5 seconds on a timer. So I created an array of colors as follows and then run the array in the timer event in vb6. Not working in vb.net. How would I do this in vb.net?
vb6 code: ----------------------------------------- Const ORANGISH As Long = &HC0C0FF Const ORYEL As Long = &HC0E0FF Const YELLOWISH As Long = &HC0FFFF Const GREENISH As Long = &HC0FFC0 Const LIGHTBLUISH As Long = &HFFFFC0 Const PURPLISH As Long = &HFFC0C0 Const PINKISH As Long = &HFFC0FF Const WHITE As Long = &HFFFFFF Dim arrColors As Variant
Private Sub Form_Load() arrColors = Array(ORANGISH, ORYEL, YELLOWISH, LIGHTBLUISH, PURPLISH, PINKISH, WHITE) End Sub
Private Sub Timer1_Timer() Static i lblRunning.BackColor = arrColors(i) i = i + 1 If i > 5 Then i = 0 End Sub ------------------------------------------------------
Here is my vb.net conversion ----------------------------------------- constants... Dim arrColors() As Long = {ORANGISH, ORYEL, YELLOWISH, GREENISH, LIGHTBLUISH, PURPLISH, PINKISH, WHITE}
Private Sub Timer1_Tick(...) Handles Timer1.Tick Static i As Integer lblRunning.BackColor = CType(arrColors(i), System.Drawing.Color) i += 1 End Sub -------------------------------------------------
The error message for vb.net says that it cannot convert a long (arrColors(i)) to System.Drawing.Color. So how could I achieve the same functionality in the vb.net app as in the vb6 app above?
Thanks
B,
I think that this sample shows the most easy
(I took only three colors)
\\\
Private arrColors(2) As Drawing.Color
Private WithEvents mytimer As New Windows.Forms.Timer
Private Sub Form2_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
mytimer.Interval = 5000
mytimer.Enabled = True
arrColors(0) = Drawing.Color.Yellow
arrColors(1) = Drawing.Color.Blue
arrColors(2) = Drawing.Color.Red
Label1.BackColor = Drawing.Color.Red
End Sub
Private Sub mytimer_Tick(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles mytimer.Tick
Static i As Integer
Label1.BackColor = arrColors(i)
i = i + 1
If i > 2 Then i = 0
End Sub
///
I hope this helps
Cor
"B" <an*******@discussions.microsoft.com> Hello,
I am trying to migrate a vb6 app to vb.net. In one piece of the vb6 app I have a label where the label backcolor changes every 5 seconds on a timer. So I created an array of colors as follows and then run the array in the timer event in vb6. Not working in vb.net. How would I do this in vb.net?
vb6 code: ----------------------------------------- Const ORANGISH As Long = &HC0C0FF Const ORYEL As Long = &HC0E0FF Const YELLOWISH As Long = &HC0FFFF Const GREENISH As Long = &HC0FFC0 Const LIGHTBLUISH As Long = &HFFFFC0 Const PURPLISH As Long = &HFFC0C0 Const PINKISH As Long = &HFFC0FF Const WHITE As Long = &HFFFFFF Dim arrColors As Variant
Private Sub Form_Load() arrColors = Array(ORANGISH, ORYEL, YELLOWISH, LIGHTBLUISH, PURPLISH, PINKISH, WHITE) End Sub
Private Sub Timer1_Timer() Static i lblRunning.BackColor = arrColors(i) i = i + 1 If i > 5 Then i = 0 End Sub ------------------------------------------------------
Here is my vb.net conversion ----------------------------------------- constants... Dim arrColors() As Long = {ORANGISH, ORYEL, YELLOWISH, GREENISH, LIGHTBLUISH, PURPLISH, PINKISH, WHITE}
Private Sub Timer1_Tick(...) Handles Timer1.Tick Static i As Integer lblRunning.BackColor = CType(arrColors(i), System.Drawing.Color) i += 1 End Sub -------------------------------------------------
The error message for vb.net says that it cannot convert a long (arrColors(i)) to System.Drawing.Color. So how could I achieve the same functionality in the vb.net app as in the vb6 app above?
Thanks
Thanks. That was the trick. (for the sake of my own
posterity I thought I would add this comment) Actually, to
keep the array of colors as numbers I had to do it this
way:
lblRunning.BackColor = ColorTranslator.FromOle(CType
(arrColors(i), Integer))
To use ColorTranslator.FromHtml I would have to set each
constant as a String and create a String array.
Const WHITE As String = "&HFFFFFF"
....
Either way works fine. Many thanks for your help. -----Original Message----- See the ColorTranslator.FromHTML method.
"B" <an*******@discussions.microsoft.com> wrote in
messagenews:1b****************************@phx.gbl... Hello,
I am trying to migrate a vb6 app to vb.net. In one
piece of the vb6 app I have a label where the label backcolor changes every 5 seconds on a timer. So I created an
array of colors as follows and then run the array in the timer event in vb6. Not working in vb.net. How would I do
this in vb.net?
vb6 code: ----------------------------------------- Const ORANGISH As Long = &HC0C0FF Const ORYEL As Long = &HC0E0FF Const YELLOWISH As Long = &HC0FFFF Const GREENISH As Long = &HC0FFC0 Const LIGHTBLUISH As Long = &HFFFFC0 Const PURPLISH As Long = &HFFC0C0 Const PINKISH As Long = &HFFC0FF Const WHITE As Long = &HFFFFFF Dim arrColors As Variant
Private Sub Form_Load() arrColors = Array(ORANGISH, ORYEL, YELLOWISH,
LIGHTBLUISH, PURPLISH, PINKISH, WHITE) End Sub
Private Sub Timer1_Timer() Static i lblRunning.BackColor = arrColors(i) i = i + 1 If i > 5 Then i = 0 End Sub ------------------------------------------------------
Here is my vb.net conversion ----------------------------------------- constants... Dim arrColors() As Long = {ORANGISH, ORYEL, YELLOWISH, GREENISH, LIGHTBLUISH, PURPLISH, PINKISH, WHITE}
Private Sub Timer1_Tick(...) Handles Timer1.Tick Static i As Integer lblRunning.BackColor = CType(arrColors(i), System.Drawing.Color) i += 1 End Sub -------------------------------------------------
The error message for vb.net says that it cannot
convert a long (arrColors(i)) to System.Drawing.Color. So how
could I achieve the same functionality in the vb.net app as in the vb6 app above?
Thanks
.
"B" <an*******@discussions.microsoft.com> schrieb: I am trying to migrate a vb6 app to vb.net. In one piece of the vb6 app I have a label where the label backcolor changes every 5 seconds on a timer. So I created an array of colors as follows and then run the array in the timer event in vb6. Not working in vb.net. How would I do this in vb.net?
Store your colors in 'Color' instances directly. You can use
'Color.FromArgb' to construct a color from RGB data, or you can use
predefined colors available in 'Color.*'.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Yes. This is the best way. I was thinking about FromArgB
but wasn't sure about the implementation. Here is what I
found on the net which gives me a whole variety of colors
Private m_Rnd As New Random
Public Function RandomRGBColor() As Color
Return Color.FromArgb(255, m_Rnd.Next(0, 255), _
m_Rnd.Next(0, 255), m_Rnd.Next(0, 255))
End Function
Thanks for this suggestion. I am amazed at how there are
so many different ways to accomplish something in vb.net. -----Original Message----- "B" <an*******@discussions.microsoft.com> schrieb: I am trying to migrate a vb6 app to vb.net. In one
piece of the vb6 app I have a label where the label backcolor changes every 5 seconds on a timer. So I created an
array of colors as follows and then run the array in the timer event in vb6. Not working in vb.net. How would I do
this in vb.net? Store your colors in 'Color' instances directly. You can
use'Color.FromArgb' to construct a color from RGB data, or
you can usepredefined colors available in 'Color.*'.
-- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: me |
last post by:
good day,
i found this message:
and i want to know more about it too.
==========================================
Hey all,
example:...
|
by: howdy |
last post by:
Hi all,
I'm trying to rotate 5 images which load from the server. My script loads
the images but when i move to the end of my array i want to cycle throught
the array again so that the images will...
|
by: Brett |
last post by:
Sorry for the rookie question....
If I have a pointer array (for example):
char *colors = {
"blue",
"green"
};
and I want to add yellow to this array later in my code....how would I do
|
by: Roger |
last post by:
Hi,
I'm trying to populate an array with color names. I keep getting an error.
Here is the line that fails:
Dim Colors As String() = Enum.GetValues(enumColor.GetType())
|
by: Stick |
last post by:
Hi,
I normally program in C++, and I'm trying to write this little tool in C#,
but I quickly realized that I can't use pointers, so instead I need to create
an array of 3 Color 's
private...
|
by: jhetfield18 |
last post by:
I have to write a program for the university as a weekly project that gets an int array as an input and the contents can only be 0 and 1.Its supposed to be a maze solver.1 as wall and you can move on...
|
by: rob |
last post by:
Hello,
If I have an array made up of a bunch of key =value pairs, how can I
pass the values of each key as an argument to a function, given that
the number of items in the array are not static...
|
by: JackpipE |
last post by:
I need to create multidimensional array with arrays inside of it.
database
name | value1 | value2
john | red | 45
john | red | 56
john | yellow | 11
mike | blue | 23
mike | black | 41
|
by: pcdinh |
last post by:
I tried to make a javascript function based on Function object and
assign it an outside data, expecting that that function will return a
string with data populated.
<script>
// Data
var colors...
|
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: 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: 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: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
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,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |