|
-
Nov 20th, 2000, 05:27 PM
#1
Thread Starter
Addicted Member
I have a problem....I want to do the following:
Form1 has lots of text boxes, and when the user fill them nd presses a button, it opens another form(form2), with all the things he has written in Form1. Also in form1, there is a combo box which lets you choose if you are a male or a female...and according wo what you choose, it says that you are a "boy" or a "girl" in form2. In form2, there is a button that says "New", which closes form2 and opens form1, but when it opens form1, the text boxes arent cleared, so I added the following code:
Form2.txtFirst.Text = " "
Form2.txtSecond.Text = " "
Form2.txtThird.Text = " "
...and so on......
the problem is with the Combo box...how can I clear it leaving the original information inside it (Male and Female)??
-
Nov 20th, 2000, 05:43 PM
#2
If you just mean to keep the original information as in keep Male and Female as options, then just do this :
Code:
For Each Control In Me
If(TypeName(Control) = "TextBox") Or (TypeName(Control) = "ComboBox") Then
Control.Text = ""
End If
Next Control
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Nov 20th, 2000, 05:52 PM
#3
_______
<?>
'stuff to start with.
'form1 sample code
Code:
Option Explicit
Private Sub Command1_Click()
Form1.Visible = False
Form2.Visible = True
Form2.Text1.Text = Form1.Text1.Text
Form2.Text2.Text = Form2.Text2.Text
Form2.text3.Text = Form1.Combo1.Text
End Sub
Private Sub Form_Load()
Combo1.AddItem "Choose your sex"
Combo1.AddItem "Boy"
Combo1.AddItem "Girl"
Combo1.ListIndex = 0
End Sub
'Form2 Sample Code
Option Explicit
'
Public Sub ClearTxt()
'
'mycontrol = control and increment is increment for forms
'some situtations use more than one form.
'
Dim ctlMyControl As Control
Dim intIncrement As Integer
'
For intIncrement = 0 To Forms.Count - 1
For Each ctlMyControl In Forms(intIncrement).Controls
'
If TypeOf ctlMyControl Is TextBox Then
'
ctlMyControl.Text = ""
'
End If
'
Next ctlMyControl
'
Next intIncrement
'
End Sub
Private Sub Command1_Click()
Call ClearTxt
Form1.Combo1.ListIndex = 0
Form2.Visible = False
Form1.Visible = True
End Sub
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|