Solved

How to Create Scrollable forms?

Posted on 1998-09-18
6
216 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
  • 4
6 Comments
 

Author Comment

by:happydanny
Comment Utility
Edited text of question
0
 

Author Comment

by:happydanny
Comment Utility
Edited text of question
0
 

Author Comment

by:happydanny
Comment Utility
I have posted this to Newsgroup but seems that no gurus is able solve the problem. Any takers?
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 6

Accepted Solution

by:
anthonyc earned 200 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
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…

763 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now