View Full Version : VB question :)
Shiori
October 23rd, 2001, 06:35
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:
kairi00
October 23rd, 2001, 07:07
Maybe something like this:
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...
Xeven
October 23rd, 2001, 07:12
im the lamest vb coder on the planet.. so i won't even try.. nyahaha:p:p:p
Shiori
October 23rd, 2001, 07:14
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:
kairi00
October 23rd, 2001, 07:21
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?
Ryos
October 23rd, 2001, 07:24
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.
Shiori
October 23rd, 2001, 07:45
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?
kairi00
October 23rd, 2001, 07:57
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 :)
Badaro
October 25th, 2001, 03:06
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
Shiori
October 25th, 2001, 05:02
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)
vBulletin® v3.8.7, Copyright ©2000-2013, vBulletin Solutions, Inc.