thanks guys

when running this code, the hscrollbar will accept any value. however, once the form is finally displayed, the hscrollbar will change it's maximum value to either 0, 22, 54, or 246. in binary "0", "10110", "110110", or "11110110". i have stepped through the code with the debugger and have verified that i am specifically setting it to other numbers (i.e. 7, 31, 255, etc.). i have also specifically set hbar.maximxum = 7 for debug purposes but when the form becomes visible the hscrollbar acts as if i have set the maximum to 0. is this a known bug i have searched MSDN to no avail...

For Each symbol In symbolList

'some code here

hBar = New System.Windows.Forms.TrackBar()

hBar.Minimum = 0

hBar.Maximum = CInt(2 ^ numbits) - 1

'more code here (adds hbar to a groupbox, adds groupbox to tabpage)

Next

thanks for your help,

Daniel



Answer this question

thanks guys

  • z-one

    my workaround was to use the trackbar instead of the hscrollbar, which worked perfectly (only had to change two lines of code to get the trackbar instead of the hscrollbar). but i will try Ken's suggestion later today.

    Thanks,

    Daniel


  • Jerry Hung

    Ah, I think Ken's got it right. Never mind...

  • JG53_Jaguar

    Hi, Daniel,

    Hmm... I gave this a try just now. First, I tried this by adding a Trackbar to the form in the designer and setting the maximum, and then running the application -- the maximum value persisted OK.

    Next, I tried adding the Trackbar dynamically like you did above (though I also added the Me.Controls.Add(hbar) line necessary to get it into the form's collection), and again the maximum persisted OK.

    In both cases, I set the maximum value to 10000. I added a Label control which tracked the current value of the trackbar, just to make sure that the slider went all the way up to 10000 when used.

    Is there a chance that you've got some code elsewhere which is changing the maximum value accidentally (like writing it instead of reading it, etc)

    --Matt--*



  • Polity4h

    Declaring hbar inside of the loop to avoid the problem you are having

    For Each ....
    Dim hBar as new Trackbar




  • RayClark096

    I have tried Ken's suggestion, and the HScrollBar still gives me odd maximum values. for instance, i manually set everything to a max value of 63, but when the form loads, they all have maximum values of 58! go figure! if i change to a TrackBar, then everything works great with the same exact code (max value of 63).
  • thanks guys