Solved

How to Create Scrollable forms?

Posted on 1998-09-18
6
223 Views
Last Modified: 2010-04-30
Dear Gurus,

        I am working on a programme such that it will create a series of label control follow by textbox control(pairs) during runtime. These are like Questions and Answers form. The catch is that we do not know how many Questions we have (read from a file). And the important part is the interface is going to be like a web browser where you can scroll down(scroll bar on the right side of screen). However, form object in VB 5.0 has no scroll bar and I am not allowed to use more than one form. Is there anyway to achieve that? How can I combine a form object and a V scroll bar control to achieve the effect?

      I had tried out some OCX control(freeware on the internet) called scrollbox.zip but I can't even register the OCX control to begin with.

        Thanks for any help I might get.

0
Comment
Question by:happydanny
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
6 Comments
 

Author Comment

by:happydanny
ID: 1435493
Edited text of question
0
 

Author Comment

by:happydanny
ID: 1435494
Edited text of question
0
 

Author Comment

by:happydanny
ID: 1435495
I have posted this to Newsgroup but seems that no gurus is able solve the problem. Any takers?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 6

Accepted Solution

by:
anthonyc earned 200 total points
ID: 1435496
Happy.. this is not too difficult.

Do this:

1)  Add a Vertical Scroll bar to your form.  Put it on the right side, and put this code in your resize event

private sub Form_Resize()
  'Resize the scrollbar so it takes the entire window
  if me.windowstate <> vbMinimized then
    vScroll1.move me.scalewidth - vscroll1.width, 0, vscroll1.width, me.scaleheight
  end if

2)  Set the VScroll1.min = 1 and the max = #questions

3)  Add 1 textbox and 1 label to your form.  Make them invisible, and set their index property to 0

4)  Write Code to load textbox/label pairs for you

private sub LoadPairs(nCount as integer)
  const sSep as single = 500

  dim nI   as integer
  dim sTop as single

  for ni = 1 to ncount
     load text1(ni)
     load label1(ni)
   
     sTop = sTop + sSep
     with label1(ni)
        .left = 60 'or whatever left you want to use
        .top = sTop
        .visible = true
     end with

     with text1(ni)
        .left = 3000
        .top = stop
        .visible = true
     end with
  next ni
end sub


5)  Now for the scrolling code

private sub vScroll1_Change()
   dim nI as integer
   const sSep as single = 500

   'The scrollbar contains which question we want on the top.
   'We must then reposition everything else based on that.

   for ni = 1 to text1().ubound
      label1(ni).top = ((ni - vscroll1.value) + 1) * sSep
      text1(ni).top = label1(ni).top
   next ni
end sub


0
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1435497
Use a picture box and two scrollbars. Place all your controls on the picturebox.
Now you can set the left and the top property of the picture to the negative value of the scrollbar values.

I can also send you some code that does this. Post a comment here and mail to Mirkwood@hotmail.com
0
 

Author Comment

by:happydanny
ID: 1435498
Dear anthonyc,

        Thanks for your fabulous answer. However, after reading Mirkwood's answer, I think it is an easier method to my goal.
        If it is possible I would like to take a look at Mirkwood's code.
        I had already setup the values including adjusting for Vscroll.max dynamically so that it scrolls smoothly for both cases when control boxes are longer than one page and when control boxes fit nicely into just one page!
        I still had some doubt about constructing a control array to when I read the questions from a txt file.
        I still had some doubt about constructing a control array when I read the questions from a txt file. I hope Mircwood's answer can kindly show me how to achieve that.



0

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

718 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question