Solved

How to Create Scrollable forms?

Posted on 1998-09-18
6
217 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
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Window placement 17 74
consolidate or create a new vba code for performing tasks 5 63
Problem to skip loop 6 54
Best way to parse out a json string in VB6? 10 109
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

919 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

17 Experts available now in Live!

Get 1:1 Help Now