Results 1 to 4 of 4

Thread: Colors problem

  1. #1
    Stiletto
    Guest

    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?

  2. #2
    PowerPoster MidgetsBro's Avatar
    Join Date
    Oct 2000
    Location
    Apparently, Internet.com
    Posts
    3,125
    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.
    <removed by admin>

  3. #3
    Stiletto
    Guest
    This is wierd.
    I'm saving the color to the file like this
    VB Code:
    1. Val(Color(i).BackColor)
    This writes me 8388608, 255, 12632064.. depending in the color
    I'm reading it like this
    VB Code:
    1. 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?

  4. #4
    Addicted Member
    Join Date
    Jul 2000
    Location
    FeedMeTown, Ohio
    Posts
    176
    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
  •  



Click Here to Expand Forum to Full Width