?
Solved

How to Create Scrollable forms?

Posted on 1998-09-18
6
Medium Priority
?
224 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
Independent Software Vendors: 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 600 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month14 days, 22 hours left to enroll

770 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