|
-
Jan 25th, 2002, 06:09 PM
#1
Colors problem
Sups,
The user is able to choose a backcolor for a label using common dialog control. Then i save the color into a txt file.
When the user opens the app again i read the color number from the txt file and put it as the backcolor of the label.
The problem is that no metter which color i'll choose, the backcolor of the label wont change!.
Ive checked my code and everything is fine, the code writes and reads from the file with no probs. The problem is that it cant convert the saved number of the color in the file to match ne color.
I guess its a Hex, Dec problem. What do to?
-
Jan 25th, 2002, 06:15 PM
#2
PowerPoster
Are you saving the color as a Long? It should work. When you load the file back in, and get the color, try using Val(LoadedColor) instead of just the number of the loaded color. This way it will make sure that it's a number, and not a string.
-
Jan 25th, 2002, 06:41 PM
#3
This is wierd.
I'm saving the color to the file like this
This writes me 8388608, 255, 12632064.. depending in the color
I'm reading it like this
VB Code:
BasicColor = Val(InputLines(1)) 'This code is good
BasicColor as a public Long.
If i MsgBox BasicColor at the end of the reading process it will show me the saved color, same as in the file.
But then, if i MsgBox BasicColor from another form it will give me 255 (Default color as i set)
What is goin on?
-
Jan 25th, 2002, 10:09 PM
#4
Addicted Member
No problems here. As long as you declare the variant as a LONG.
Private Sub cmdColor_Click()
Dim lColor As Long
lColor = Val(txtColor.Text)
Label1.BackColor = lColor
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|