A Form In A Ctrl Array And Then...
I am making a Form Control Array, that part I have down pat. But then trying to get a PictureBox to be different sizes, in each of them. Or atleast it can be, if you choose the same command button to do that, then it will be the same. The sizes of the PictureBox is pre-defined at design-time and assigned to a Command Button as such.
How can I do this, and make it work right. I have tried everything. So then trying to ask the Lex-Mechanics (Programmers) of the Forum to help me.
Here is the current Source Code that I am working on...
Code:
Public Sub Command1_Click()
On Error Resume Next
Dim NF As New Form11
ReDim Preserve F(CountOfForms) As Form
If Form2.Text4.Text = "0" Then
l = 0
l = l + 1
Else
If Form2.Text4.Text = "" Then
l = l + 1
End If
End If
Filename = Form2.Text2.Text
Load NF
NF.Hide
Set F(CountOfForms) = NF
CountOfForms = CountOfForms + 1
Rem This is the Exit Sub.
If Form2.Text1.Text = "0" Then
Exit Sub
Else
Rem This is the Open.
If Form2.Text1.Text = "1" Then
NF.TitleBar1.Visible = True
NF.MenuBar1.Visible = False
NF.BackGround1(Form1.List1.ItemData(Form1.List1.ListIndex)).Height = 320
NF.BackGround1(Form1.List1.ItemData(Form1.List1.ListIndex)).Width = 460
Else
Rem This is the Save As.
If Form2.Text1.Text = "2" Then
NF.TitleBar1.Visible = True
NF.MenuBar1.Visible = False
NF.BackGround1(Form1.List1.ItemData(Form1.List1.ListIndex)).Height = 320
NF.BackGround1(Form1.List1.ItemData(Form1.List1.ListIndex)).Width = 460
Else
Rem This is the Colour Chooser.
If Form2.Text1.Text = "4" Then
NF.TitleBar1.Visible = True
NF.MenuBar1.Visible = False
NF.BackGround1(Form1.List1.ItemData(Form1.List1.ListIndex)).Height = 320
NF.BackGround1(Form1.List1.ItemData(Form1.List1.ListIndex)).Width = 460
Else
Rem This is the Printer Setup.
If Form2.Text1.Text = "5" Then
NF.TitleBar1.Visible = True
NF.MenuBar1.Visible = False
NF.BackGround1(Form1.List1.ItemData(Form1.List1.ListIndex)).Height = 320
NF.BackGround1(Form1.List1.ItemData(Form1.List1.ListIndex)).Width = 460
Else
Rem This is the Font Chooser.
If Form2.Text1.Text = "6" Then
NF.TitleBar1.Visible = True
NF.MenuBar1.Visible = False
NF.BackGround1(Form1.List1.ItemData(Form1.List1.ListIndex)).Height = 320
NF.BackGround1(Form1.List1.ItemData(Form1.List1.ListIndex)).Width = 460
Else
Rem This is the Dialog Box.
If Form2.Text1.Text = "7" Then
NF.TitleBar1.Visible = True
NF.MenuBar1.Visible = False
NF.BackGround1(Form1.List1.ItemData(Form1.List1.ListIndex)).Height = 320
NF.BackGround1(Form1.List1.ItemData(Form1.List1.ListIndex)).Width = 460
Else
Rem This is the User Form.
If Form2.Text1.Text = "8" Then
NF.TitleBar1.Visible = True
NF.MenuBar1.Visible = True
NF.BackGround1(Form1.List1.ItemData(Form1.List1.ListIndex)).Height = 900
NF.BackGround1(Form1.List1.ItemData(Form1.List1.ListIndex)).Width = 1400
Else
Rem This is the Video in a Window.
If Form2.Text1.Text = "9" Then
NF.TitleBar1.Visible = True
NF.MenuBar1.Visible = False
NF.BackGround1(Form1.List1.ItemData(Form1.List1.ListIndex)).Height = 200
NF.BackGround1(Form1.List1.ItemData(Form1.List1.ListIndex)).Width = 460
Else
Rem This is the Splash Screen.
If Form2.Text1.Text = "10" Then
Form10.Combo16.Enabled = True
Form10.Combo16.AddItem "Form" & l
NF.TitleBar1.Visible = False
NF.MenuBar1.Visible = False
NF.BackGround1(Form1.List1.ItemData(Form1.List1.ListIndex)).Height = 480
NF.BackGround1(Form1.List1.ItemData(Form1.List1.ListIndex)).Width = 720
Else
Rem This is the Message Box.
If Form2.Text1.Text = "11" Then
NF.TitleBar1.Visible = True
NF.MenuBar1.Visible = False
NF.BackGround1(Form1.List1.ItemData(Form1.List1.ListIndex)).Height = 300
NF.BackGround1(Form1.List1.ItemData(Form1.List1.ListIndex)).Width = 720
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
NF.Hide
Form1.cmd_MakeMenu1.Enabled = True
Form1.MenuBar_Insert.Enabled = True
Form1.List1.AddItem "Form" & l & ":" & " " & Filename & ".frm"
Form1.List1.ItemData(Form1.List1.NewIndex) = l
Form12.Combo4.AddItem "Form" & l
Form12.Combo4.ItemData(Form12.Combo4.NewIndex) = l
Form10.Combo19.AddItem "Form" & l
Form12.List1.AddItem "Form" & l
Form12.lstKeywords.AddItem "Form" & l
Form14.Combo2.AddItem "Form" & l
Form14.Combo1.AddItem "Form"
Form2.Hide
Form10.Hide
Form12.Hide
Form13.Hide
Form14.Hide
Form2.Text1.Text = "0"
Form2.Text2.Text = "Untitled" & ".frm"
Form1.Text2.Text = "1"
Form2.Text4.Text = ""
Form1.DrawGuides_View.Enabled = True
Form2.Text2.Enabled = False
Form2.Command1.Enabled = False
Form1.Enabled = True
Form10.Enabled = True
Form11.Enabled = True
Form12.Enabled = True
Form13.Enabled = True
Form14.Enabled = True
End Sub
!! Thanks in advance !!
Re: A Form In A Ctrl Array And Then...
you should be indenting your code much better, each if should be indented from the previous
i believe you would be much better off using elseif, or even better using a
select case form2.text1.text
do i assume your picturebox is background1?
what happens with the code as it is now?
Re: A Form In A Ctrl Array And Then...
Well it works, and I have been doing it that way for a longtime!!
Also: What is the command to select a certain type of element in a control array, in this case it is a Form Control Array???
Thanks in advance!!
Re: A Form In A Ctrl Array And Then...
Quote:
Originally Posted by
ThEiMp
Well it works, and I have been doing it that way for a longtime!!
That still doesn't make it right.
Here are some good reads for code indenting: http://en.wikipedia.org/wiki/Indent_style
programming style http://en.wikipedia.org/wiki/Programming_style and naming conventions http://en.wikipedia.org/wiki/Identif...ing_convention most notably the Hungarian notation http://en.wikipedia.org/wiki/Hungarian_notation
Quote:
Also: What is the command to select a certain type of element in a control array, in this case it is a Form Control Array???
Code:
Dim c As Control
For Each c In Form1.Controls
If TypeOf c Is TextBox Then
c.ForeColor = vbRed
End If
Next
Re: A Form In A Ctrl Array And Then...
Can someone please help me, I am in deed in trouble with this section of code???
Re: A Form In A Ctrl Array And Then...
Quote:
Well it works, and I have been doing it that way for a longtime!!
Quote:
Can someone please help me, I am in deed in trouble with this section of code???
what problem do you have? please clarify your question
Quote:
Also: What is the command to select a certain type of element in a control array, in this case it is a Form Control Array???
what does this mean?
Re: A Form In A Ctrl Array And Then...
The reason they are asking you to indent your code is so they can HELP YOU.
It is easy for the author to know what hard-to-read code is, they wrote it! But for someone who has to figure it out, writing it in a confusing manner makes it difficult. Why would you want to make it hard for people to help you? Here's a hint: the easier you make it for people to help you the more likely you are to get help. We want to help, but can't if it is too difficult.
Not sure what you mean by
Quote:
What is the command to select a certain type of element in a control array, in this case it is a Form Control Array???
If you mean assign one, then you would do it like this:
Code:
ctl = NF.BackGround1(intIndex)
See how I prefixed the index with int. It communicates to you that it is an integer so you have a better understanding. That's one of the things baja_vu was trying to tell you.
If you mean select it on the form then:
Code:
NF.BackGround1(intIndex).SetFocus
Re: A Form In A Ctrl Array And Then...
Quote:
It is easy for the author to know what hard-to-read code is,
not even the author after a few months
Re: A Form In A Ctrl Array And Then...
Let me get this right here, before I try it out on my project???
Code:
Option Explicit
'
Dim intIndex As Integer
'
Right???
Code:
Public Sub Command1_Click()
ctl = NF.BackGround1(intIndex).Height = 240
ctl = NF.BackGround1(intIndex).Width = 180
End Sub
Right???
Re: A Form In A Ctrl Array And Then...
no
ctl = NF.BackGround1(intIndex).Height = 240
ctl will be true or false depending on the height of nf.background1(intindex)
Re: A Form In A Ctrl Array And Then...
Problem: I tried your source code. It didn't work. No change in the flow of the processes.
I am trying to get the .Height and the .Width of a PictureBox on a certain Form to be a different size. This is set or rather defined at run-time of the program.
Re: A Form In A Ctrl Array And Then...
Quote:
NF.BackGround1(Form1.List1.ItemData(Form1.List1.ListIndex)).Height = 320
what is in form1.list1.itemdata for that index?
is background1 a control array?
if so is it dynamically created?
Re: A Form In A Ctrl Array And Then...
Form1.List1.ItemData (l = l + 1), everytime it is executed.
Form11.BackGround1 = A Form Ctrl Array.
And yes it is dynamically created at run-time.
Re: A Form In A Ctrl Array And Then...
i rewrote the first section of your code, to make it more readable and understandable for others, it will also run faster as there is many fewer conditions to evaluate
are the height and width of background1 not being changed in your existing code?
can you post form11?
vb Code:
Dim NF As New Form11, idx As Integer
ReDim Preserve F(CountOfForms) As Form
If Form2.Text4.Text = "0" Then l = 0
l = l + 1
Filename = Form2.Text2.Text
Load NF
NF.Hide
Set F(CountOfForms) = NF
CountOfForms = CountOfForms + 1
idx = Form1.List1.ItemData(Form1.List1.ListIndex)
Select Case Val(Form2.Text1.Text)
'Rem This is the Exit Sub.
Case 0: Exit Sub
'Rem This is the Open, saveas, color, printer, font, dialog
Case 1, 2, 4 To 7
' all use same setting
NF.TitleBar1.Visible = True
NF.MenuBar1.Visible = False
NF.BackGround1(idx).Height = 320
NF.BackGround1(idx).Width = 460
'Rem This is the User Form.
Case 8
NF.TitleBar1.Visible = True
NF.MenuBar1.Visible = True
NF.BackGround1(idx).Height = 900
NF.BackGround1(idx).Width = 1400
'Rem This is the Video in a Window.
Case 9
NF.TitleBar1.Visible = True
NF.MenuBar1.Visible = False
NF.BackGround1(idx).Height = 200
NF.BackGround1(idx).Width = 460
'Rem This is the Splash Screen.
Case 10
Form10.Combo16.Enabled = True
Form10.Combo16.AddItem "Form" & l
NF.TitleBar1.Visible = False
NF.MenuBar1.Visible = False
NF.BackGround1(idx).Height = 480
NF.BackGround1(idx).Width = 720
'Rem This is the Message Box.
Case 11
NF.TitleBar1.Visible = True
NF.MenuBar1.Visible = False
NF.BackGround1(idx).Height = 300
NF.BackGround1(idx).Width = 720
Case Else
'in case some other value is entered
End Select
NF.Hide
Re: A Form In A Ctrl Array And Then...
Form11, is just adding the ActiveX controls to the Form. Eg: Point and Click on the PictureBox that meant to be all on Form11. But the buttons in the ToolBox are found on Form1, and so are the other processes found in Form1. eg: Menus, etc...
Anyway: Here it is in a downloadable version. Cause I am not quite sure how many lines the CODE tags are able to take???
Re: A Form In A Ctrl Array And Then...
Quote:
are the height and width of background1 not being changed in your existing code?
you still did not answer on this
Re: A Form In A Ctrl Array And Then...
Sorry...
Yes, the .Height and .Width can be changed if you user wishes to do so. But there are .Height and .Width default settings, which can be changed when the program is in the Design Mode. (My Program's Design Mode, which is its run-time for the project).
Also now I changed the code to work with different buttons to select different Form types. Like ActiveX control to UserForm types. To make it more simpler, I was thinking. Now it looks, a right mess in deed!!
If I post this file, as a downloadable version could you have a look. I am going to run it through an external debugger, to get what is really going on with it!!
And I don't think that I should have said, that? Because no one on the outside of my project headquaters. Should know of that program, that they exist!!