Next Generation Emulation banner

1 - 10 of 10 Posts

·
playing FGO
Joined
·
10,133 Posts
Discussion Starter #1 (Edited)
im a moron when it comes to Visual basic, so i hope you can help me out on this. :emb:


is there any way i can make these chain of instructions shorter?

If intAnswer = vbYes Then
lblMessage2.Caption = " "
txtMessage.Text = " "
optBlue.Value = False
optCyan.Value = False
optMagenta.Value = False
optGreen.Value = False
optRed.Value = False
optYellow.Value = False
chkBold.Value = False
chkItalic.Value = False
chkStrikethru.Value = False
chkUnderline.Value = False
End if


hope you can help me out on this.
:emb:
 

·
Registered
Joined
·
2,853 Posts
Maybe something like this:
Code:
If intAnswer = vbYes Then
     For Each control1 in Controls
          Select Case TypeName(control1)
               Case "Label", "TextBox"
                    control1.Caption = ""
               Case "OptionBox", "CheckBox"
                    control1.Value = False
          End Select
     Next
End If
It's a bit shorter...
 

·
playing FGO
Joined
·
10,133 Posts
Discussion Starter #4
whoa, that's way beyond our current lessons. :p tried pasting the code in my little proggy, but it gave me errors. :p specifically in the "(control1)". what do i have to replace it with to work? :confused:
 

·
Registered
Joined
·
2,853 Posts
Oh whoops... I think change this line:
For Each control1 in Controls

to the following:
For Each control1 in Form1.Controls

or whatever it is your form is called... if your form is called "MyForm", then change it to "MyForm.Controls"...

This uses the Controls collection in VB... if you haven't learned collections yet, then this is jumping ahead in the course material :p

Which version of VB are you using, btw?
 

·
Registered
Joined
·
11,307 Posts
Early programming lessons always teach you the incredibly long way to program. It's only later you learn the shortcuts. Hmm...kind of like math, except there comes a point where there ARE no shortcuts. Sigh.
 

·
playing FGO
Joined
·
10,133 Posts
Discussion Starter #7
Originally posted by kairi00
Oh whoops... I think change this line:
For Each control1 in Controls

to the following:
For Each control1 in Form1.Controls

or whatever it is your form is called... if your form is called "MyForm", then change it to "MyForm.Controls"...

This uses the Controls collection in VB... if you haven't learned collections yet, then this is jumping ahead in the course material :p

Which version of VB are you using, btw?

VB6 Pro SP3. :)

...no, i haven't learned "collections" yet.... in fact, i don't know a damn thing (figuratively :p)

midterms on this is on Oct. 30. :(

in the library, though, i found an M$ book, VB6 Programmer's Edition. It's as thick as a phonebook. :( can newbies handle this thing?
 

·
Registered
Joined
·
2,853 Posts
Originally posted by Keiichi

VB6 Pro SP3. :)

...no, i haven't learned "collections" yet.... in fact, i don't know a damn thing (figuratively :p)

midterms on this is on Oct. 30. :(

in the library, though, i found an M$ book, VB6 Programmer's Edition. It's as thick as a phonebook. :( can newbies handle this thing?
Hmm... I can't say anything about the book... everything I know about VB, 15% I learned from Bruce McKinney's "Hardcore Visual Basic", 80% from an 8-month internship experience , 5% from MSDN. :p

Well, good luck with the midterm dude... I'm sure you'll do just fine :)
 

·
I'm in despair!
Joined
·
3,420 Posts
Originally posted by Keiichi



VB6 Pro SP3. :)

...no, i haven't learned "collections" yet.... in fact, i don't know a damn thing (figuratively :p)

midterms on this is on Oct. 30. :(

in the library, though, i found an M$ book, VB6 Programmer's Edition. It's as thick as a phonebook. :( can newbies handle this thing?
I don't recommend the MS Press books unless you want to get a MS Certification. Oh, and why don't you update to SP5.

[]s Badaro
 

·
playing FGO
Joined
·
10,133 Posts
Discussion Starter #10
it's the school's proggy. :p at home i use my uncle's Enterprise edition. (but i cant make him teach me...he's always out of the country. :p)
 
1 - 10 of 10 Posts
Top