SunQuest
           Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old November 4th, 2003, 10:03 AM
fletchsod's Avatar
fletchsod fletchsod is offline
I lov C in AIX/Linux, hate C++
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Location: Jacksonville, Florida
Posts: 1,497 fletchsod User rank is Corporal (100 - 500 Reputation Level)fletchsod User rank is Corporal (100 - 500 Reputation Level)fletchsod User rank is Corporal (100 - 500 Reputation Level)fletchsod User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Week 2 Days 16 h 56 m 32 sec
Reputation Power: 8
Array Issue like Array('one'), Array('two'), etc...

I know that in PHP, the array can be like this...

--snip--
$Array['red'] = "FF0000";
$Array['blue'] = "00FF00";
$Array['black'] = "000000";

echo $Array['black'];
--snip--

But in visual basic, how do I make this work...

--snip--
dim strArray as string

strArray(red) = "FF0000"
strArray(blue) = "00FF00"
strArray(black) = "000000"

frmForm.txtText.text = strArray(black)
--snip--

Am I doing something wrong? Does it work or what? I only see from the internet search that only integer can be use like 0, 1, 2, 3, etc..

Thanks,
Scott F.

Reply With Quote
  #2  
Old November 4th, 2003, 12:20 PM
Fisherman's Avatar
Fisherman Fisherman is offline
Inherits Programmer.Slacker
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Aug 2003
Location: Between my Id and your Ego
Posts: 2,171 Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 9 h 1 m 37 sec
Reputation Power: 110
Send a message via ICQ to Fisherman Send a message via AIM to Fisherman
well, one possible solution would be declare a public constant to represent your colors....

I used the RGB Function instead of hex, and wrote this small example

Code:
Const Black As Integer = 0
Const Red As Integer = 1
Private Sub Form_Load()
Dim aryColors(2) As Integer
Dim strInput As String
aryColors(Black) = RGB(0, 0, 0)
aryColors(Red) = RGB(255, 0, 0)
strInput = CStr(InputBox("What color would you like the form to be?", "Color Preference"))
Select Case strInput
    Case "Black"
        Form1.BackColor = aryColors(Black)
    Case "Red"
        Form1.BackColor = aryColors(Red)
    Case Else
        MsgBox "The Color you Entered is not valid.  Will Default to Black", vbOKOnly, "Invalid"
        Form1.BackColor = aryColors(Black)
End Select

End Sub
__________________
Fisherman

"Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius -- and a lot of courage -- to move in the opposite direction." - A.Einstein

Reply With Quote
  #3  
Old November 4th, 2003, 12:23 PM
Fisherman's Avatar
Fisherman Fisherman is offline
Inherits Programmer.Slacker
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Aug 2003
Location: Between my Id and your Ego
Posts: 2,171 Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 9 h 1 m 37 sec
Reputation Power: 110
Send a message via ICQ to Fisherman Send a message via AIM to Fisherman
I just thought, I'm fairly sure that VB does not like Hex unless it is enclosed in "#"s. so, if you're going to do "000000", then, it should be "#000000#", but I don't know if it will like the hex value as a string anyway...I'll try it though!

Reply With Quote
  #4  
Old November 4th, 2003, 01:10 PM
fletchsod's Avatar
fletchsod fletchsod is offline
I lov C in AIX/Linux, hate C++
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Location: Jacksonville, Florida
Posts: 1,497 fletchsod User rank is Corporal (100 - 500 Reputation Level)fletchsod User rank is Corporal (100 - 500 Reputation Level)fletchsod User rank is Corporal (100 - 500 Reputation Level)fletchsod User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Week 2 Days 16 h 56 m 32 sec
Reputation Power: 8
Thanks for the clarification. Gee, look like Visual Basic doesn't have that flexibility with the array. Seem it work only with integer value in the array. Dynamic array is tricker here in visual basic. Oh well, I guess we all have to live with it.

Thanks...

Reply With Quote
  #5  
Old November 4th, 2003, 08:55 PM
cleverpig cleverpig is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Posts: 1,152 cleverpig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via MSN to cleverpig
I provider a function which can Chang long color value to RGB color value function!

Public Function ColorCodeToRGB(lColorCode As Long, iRed As Integer, iGreen As Integer, iBlue As Integer) As Boolean
' 1996/01/16 Return the individual colors for lColorCode.
' 1996/07/15 Use Tip 171: Determining RGB Color Values, MSDN July 1996.
' Enter with:
' lColorCode contains the color to be converted
'
' Return:
' iRed contains the red component
' iGreen the green component
' iBlue the blue component
'
Dim lColor As Long
lColor = lColorCode 'work long
iRed = lColor Mod &H100 'get red component
lColor = lColor \ &H100 'divide
iGreen = lColor Mod &H100 'get green component
lColor = lColor \ &H100 'divide
iBlue = lColor Mod &H100 'get blue component

ColorCodeToRGB = True
End Function

See more information:
http://www.buygold.net/v02n04/v02n04.html

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > Array Issue like Array('one'), Array('two'), etc...


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway