I need to finish a program, i found it in a book but the for statement is now finised. I don't know to finish it, anybody can help me, please?

Private Sub Form_Load()
For i = 1 To Screen.FontCount - 1
Combo1.AddItem Screen.Fonts(i)
Next
For i = 5 To 300
Combo1.ListIndex = 0
Combo2.ListIndex = 5



End Sub

Recommended Answers

All 6 Replies

It would help if you described what exactly you want to do. Your second For loop is not closed with a Next and it doesn't use the iterator "i".

You need to provide more details like, what the program is intended to do? moreover, if you carefully observe the second "for" loop isn't terminated and next two statements doesn't make sense to be part of the loop. If you can elaborate more on what you want to achieve using this program, it will be helpful to answer your question.

commented: i've put the code, please check it +0

a few things :

Private Sub Form_Load()
For i = 1 To Screen.FontCount - 1
Combo1.AddItem Screen.Fonts(i)
Next

the above statment will load all fonts available in combo1. ok.

For i = 5 To 300
Combo1.ListIndex = 0
Combo2.ListIndex = 5

End Sub

here i don't why are you using loop here because it will give no sense. so remove for loop and if you don't wanna remove the loop then just put Next statement before End Sub. ok.

one more thing, why are you using Combo2.ListIndex = 5 ?
i don't see where you are assigning values to combo2 and you are selecting its 6th element.So this will also generates some errors and you should also remove this statement. ok.

after putting all these correctly , you code will look like :

Private Sub Form_Load()
For i = 1 To Screen.FontCount - 1
Combo1.AddItem Screen.Fonts(i)
Next
Combo1.ListIndex = 0
End Sub

hope this helps you.

i want to make a colour change program, which i've already design it, and done all the buttons.
i put all code here, so that you can understand what i want to do.

Private Sub Check1_Click()
Dim fnt As Font
Set fnt = Text1.Font
If Check1.Value = vbChecked Then
fnt.Bold = True
Else
fnt.Bold False
End If
End Sub

Private Sub Check2_Click()
Dim fnt As Font
Set fnt = Text1.Font
If Check2.Value = vbChecked Then
fnt.Italic = True
Else
fnt.Italic = False
End If
End Sub

Private Sub Combo1_Click()
Text1.FontName = Combo1
End Sub

Private Sub Combo2_Click()
Text1.FontSize = Combo2
End Sub

Private Sub Command1_Click()
Open "C:\Mamun.doc" For Output As 1
Print #1, Text1.Text
Close #1
End Sub

Private Sub Command2_Click()
Text1 = " "
Text1.SetFocus
End Sub

Private Sub Command3_Click()
CD.ShowColor
Text1.ForeColor = CD.Color
End Sub

Private Sub Command4_Click()
End
End Sub

Private Sub Form_Load()
For i = 1 To Screen.FontCount - 1
Combo1.AddItem Screen.Fonts(i)
Next
For i = 5 To 300
Combo1.ListIndex = 0
Combo2.ListIndex = 5



End Sub

Private Sub Check3_Click()
Dim fnt As Font
Set fnt = Text1.Font
If Check3.Value = vbChecked Then
fnt.Underline = True
Else
fnt.Underline = False
End If
End Sub

In Check1_Click() Procedure
change fnt.Bold False to fnt.Bold = False

In Form_Load() Procedure

For i = 1 To Screen.FontCount - 1
Combo1.AddItem Screen.Fonts(i)
Next
For i = 0 To 36
Combo2.AddItem i
i = i + 1
Next

hope this helps you.

commented: wow thank you very much, it helped me a lot, now i succed +0

if it really helped you then mark this thread as solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.