Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ssTab Vb6 creating multple tabs at run time 1

Status
Not open for further replies.

cyberbiker

Programmer
Mar 16, 2001
431
US
I am using the ssTab Control in VB6 and trying to create New Tabs "on the fly" I am able to create the tabs ok along with the proper captions but when I try to have the controls on tab0 appear on additional tabs. I get an illegal operation and VB shuts down.
I am fairly new at this, and although I have a couple of years programming experience with CoBOL and PL/N, this is my first VB job. I have only been with it a month and am a bit desperate for an answer before my new boss finds out I do not know how to do this. :)

The applicable code is as follows:
Please note the offending code is NOT split to multiple lines in the actual program.

Public Sub FindGroups()
intGroupCount = 0
Do Until EOF(intfile1)
strLine = ""
Line Input #intfile1, strLine
strLine = Trim(strLine)

If Left(strLine, 1) = "[" Then
lngPos = InStr(1, strLine, "]")
strGroup = UCase(Trim(Mid(strLine, 2, (lngPos - 2))))
intGroupCount = intGroupCount + 1

frmUpdate.tabParam.Tabs = intGroupCount
frmUpdate.tabParam.TabCaption(intGroupCount - 1) = strGroup

'Next line of code is the issue when not commented out

Set frmUpdate.tabParam.Container(intGroupCount) = frmUpdate.tabParam.Container(0)

'number of tabs start at one. index of tabs start at 0
'thus intGroupCount - 1 is necessary or else would
'need 2 counters


End If

Loop 'While Not EOF(intfile1)


Exit Sub
Close #intfile1
End Sub

If the indicated line is commented out the tabs are created fine with the proper captions.
If I set a watch frmUpdate.tabParam.TabCaption(intGroupCount - 1) and intCount increment properly But if that line is in then the watch window shows as both being "1" then "2"
then "2" again then "4" then "2" again then "6" then "2" again then "8" then "2" then I receive an illegal operation
frmUpdate.tabParam.Container(0) = false in watch.
Thanks for reading this.
Terry
 
I haven't played with this, but in looking at the code and through a book I have, the book uses
Code:
 set <control>.Container = <a container>
where <control> is a button, label... whatever.

It seems that your code is setting one container to another. Have you tried (tediously) setting the items in tab 0's container property to the new tab?

~Melissa
 
you have not that nead !

Dim intGroupCount As intger
Dim i As Integer
intGroupCount = 0
For i = 0 To 5
intGroupCount = intGroupCount + 1
Next
TabParam.Tabs = intGroupCount

' Set TabParam.Container(intGroupCount) = TabParam.Container(0)

it create 5 Tabs and the focus is on Tab 0

Eric De Decker
vbg.be@vbgroup.nl

License And Copy Protection AxtiveX.

Download Demo version on my Site:
 
to those who sent me an answer. I appreciate the information.
Unfortunately I discovered that what I wished to do would not work. Apparently my attemt to copy the controls to each tab does not actually create controls on each new tab. ie:I wish to change information in combo boxes on each tab seperatlely.
The plan was to create a variable number of tabs with a set number of controls that would be either visible or not depending. then each control was to be used further.
Apparently, I had an erroneous idea re: the container property.
I will need to draw controls on each tab at run time as needed.
Your help is appreciated greatly though.
Terry
 
Create Controls at Run-Time :

Option Explicit

Dim WithEvents txtMain As TextBox
Dim WithEvents lstMain As ListBox

Private Sub Form_Load()
'Create and Set Up Controls
Set txtMain = Me.Controls.Add(&quot;vb.textbox&quot;, &quot;txtMain&quot;, Me)
txtMain.Text = &quot;&quot;
txtMain.Visible = True

'Setting the OLEDragMode to automatic makes _
detecting a drag operation much easier than _
monitoring the mouse position
txtMain.OLEDragMode = vbOLEDragAutomatic
Set lstMain = Me.Controls.Add(&quot;vb.listbox&quot;, &quot;lstMain&quot;, Me)
lstMain.Clear
lstMain.Visible = True

'We'll handle all the Drop logic
lstMain.OLEDropMode = vbOLEDropManual
End Sub

Private Sub Form_Activate()
Static bRunOnce As Boolean

If Not bRunOnce Then
MsgBox &quot;Type tekst in de TextBox control en dragged naar de ListBox control&quot;
bRunOnce = True
End If
End Sub

Private Sub Form_Resize()
If Me.ScaleHeight < 990 Or Me.ScaleWidth < 1095 Then
Exit Sub
End If

txtMain.Move 120, 120, Me.ScaleWidth - 240, 315
lstMain.Move 120, 555, Me.ScaleWidth - 240, _
Me.ScaleHeight - 675
End Sub

succes with the ssTab an create controls at run-time Eric De Decker
vbg.be@vbgroup.nl

License And Copy Protection AxtiveX.

Download Demo version on my Site:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top