Link to home
Start Free TrialLog in
Avatar of aanimesh
aanimesh

asked on

how to clear dynamic textboxes placed on the screen and how to scroll down if all text boxes cannot be displayed

hi all,

Using the code below in a loop i am printing text boxes dyanamically that contain text from an array.

<vb>
 Call Controls.Add("VB.TextBox", "Text" & CStr(iCount), Controls(sFrame))
                Load Text0(iCount)
                Set Text0(iCount).Container = Controls(sFrame)
                With Text0(iCount)
                    .Visible = True
                   
                    .Width = 3035 + width1
                    .Top = 200 + (x * (height1 + 350))
                    '.Tag = .Top
                    .Tag = MessageArray2(pathArray(i), 1)
                    .Left = 1000
                    .Height = 315 + height1
                      .Text = MessageArray2(pathArray(i), 2)
                                       
                End With
                Controls.Remove "Text" & CStr(iCount)
----------------------------------------------------------------------------
</vb>          

this number of elements can be different everytime the procedure is called. so, if there were 5 messges in last array and next array has only 3, still the last 2 test boxes can be seen. I want to clear the screen before i print new array in textboxes.

I had earlier posted the same question....though i selected a comment as an answer, it does not solve my problem (as i am using a control array).

Please look at the detailed problem statement and proposed answers at this site (to get more clear idea about what I am trying to do):
https://www.experts-exchange.com/questions/20804600/how-to-clear-dynamic-textboxes-placed-on-the-screen-and-how-to-scroll-down-if-all-text-boxes-cannot-be-displayed.html

Thanks a lot
animesh
SOLUTION
Avatar of ashoooo
ashoooo

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of aanimesh
aanimesh

ASKER

hi ashoo,

i had deleted this question before you answered....as i had sudhakar mailed me a sample code that works (in response to my previous question thread on the same matter). but don;t know how it reappeared...

sudhakar was busy in his work, so could not reply back for some time. I wanted an answer so thought of posting the question again.

i have asked the moderator to delete this question. let me know if you have any objections. i have some other questions regarding scrolling etc..hope you will look at them and advice me if you know the solution.

the code sent by sudhakar is as follows"
<vb>

 Dim prevcount

Private Sub Command1_Click()
On Error Resume Next
For i = 1 To Val(Text2.Text)
Dim a As TextBox
   Load Text1(i)
   Text1(i).Visible = True
   Set a = Text1(i)
       a.Move prev.Left, _
        prev.Top + prev.Height + 30, _
        prev.Width, prev.Height
   a.Text = a.Name
   
   Set prev = a

   
   
Next i
prevcount = Val(Text2.Text)

End Sub

Private Sub Command2_Click()

For i = 1 To prevcount
Dim a As TextBox
   Unload Text1(i)
   
   
   
Next i
End Sub

Private Sub Form_Load()
prevcount = 0
End Sub
</vb>


thanks a lot...
Ashoo, I looked at your comment

It seems that you identified the problem correctly and i guess that your method would work.

the code that i was modifying was from an old code written by someone else, so i had no idea what was going on...i was just doing minor modification to fit my needs.
I think that what you have suggested is the same as sudhakar. Am i right?

Anyway, if you guys want i can split the points between both of you.
Or else i will again come to you (SOooon) with another question and then you can take these points.

thanks a lot...
animesh
I dont have an objection, aani. Go ahead and ask the moderator to delete it if you like.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
hi all,

EXPLANATION For giving 100 points to just an "OK" comment: read below

i told moderater not to delete this question. Wanted to acknowledge the help given by ashooo..
also since sudhakar (in the meanhwile) provided me the solution to  the same problem which i had posted as a different thread (see:
https://www.experts-exchange.com/questions/20804600/how-to-clear-dynamic-textboxes-placed-on-the-screen-and-how-to-scroll-down-if-all-text-boxes-cannot-be-displayed.html )

i asked him to post something here too...so that i can recognise his solution (also for people who have the same question can get a better picture of the solution) and give points to him for his efforts.