How increase i

P

Provart

I have Userform, i need increment "i" with CommandButton4. This is my code,
Tnx for Help.

Private Sub CommandButton1_Click()
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = TextBox1
.Forward = True
.Wrap = wdFindAskListBox
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute
End Sub

Private Sub CommandButton2_Click()
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = TextBox1
.Replacement.Text = TextBox2
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceOne
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = TextBox1
Selection.Find.Execute
End With
End Sub

Private Sub CommandButton3_Click()
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = TextBox1
.Replacement.Text = TextBox2
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub

Private Sub CommandButton3_Click()

End Sub

Private Sub UserForm_Initialize()
Dim MyArray As Variant
Dim TyArray As Variant
MyArray = Array(" ", "([a-z])^13")
TyArray = Array(" ", "\1 ")
UserForm1.TextBox1() = MyArray(0 + i)
UserForm1.TextBox2() = TyArray(0 + i)
UserForm1.Show
End Sub
 
D

Doug Robbins - Word MVP

Private Sub CommandButton4_Click()
i = i + 1
End Sub


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
P

Provart

Doug Robbins - Word MVP said:
Private Sub CommandButton4_Click()
i = i + 1
End Sub


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
Provart said:
I have Userform, i need increment "i" with CommandButton4. This is my
code, Tnx for Help.

Private Sub CommandButton1_Click()
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = TextBox1
.Forward = True
.Wrap = wdFindAskListBox
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute
End Sub

Private Sub CommandButton2_Click()
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = TextBox1
.Replacement.Text = TextBox2
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceOne
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = TextBox1
Selection.Find.Execute
End With
End Sub

Private Sub CommandButton3_Click()
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = TextBox1
.Replacement.Text = TextBox2
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub

Private Sub CommandButton3_Click()

End Sub

Private Sub UserForm_Initialize()
Dim MyArray As Variant
Dim TyArray As Variant
MyArray = Array(" ", "([a-z])^13")
TyArray = Array(" ", "\1 ")
UserForm1.TextBox1() = MyArray(0 + i)
UserForm1.TextBox2() = TyArray(0 + i)
UserForm1.Show
End Sub

Sorry, but your suggestion does not work: (
Or maybe I have misunderstood me.
 
D

Doug Robbins - Word MVP

What is it that you really want Command Button 4 to do?

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
P

Provart

Doug Robbins - Word MVP said:
What is it that you really want Command Button 4 to do?
I wont:
UserForm1.TextBox1() = MyArray(0 + i)
UserForm1.TextBox2() = TyArray(0 + i)
i = 1 then i click Command Button 4
i = 2 then i click Command Button 4
i = 3 then i click Command Button 4
Sorry for may english, i am Italian :(
 
F

fumei via OfficeKB.com

You need to understand Scope. The variable i must be in Scope to be used.

Are you using Option Explicit?

Where are you declaring i? Is it Public?
 
D

Doug Robbins - Word MVP

Like this
Option Explicit
Dim i As Long
Dim myarray As Variant
Private Sub CommandButton1_Click()
'Create the array and show the first item in the Text Box
i = 0
myarray = Split("one\two\three\four\five\six\seven\eight\nine", "\")
TextBox1.Text = myarray(i)
End Sub

Private Sub CommandButton2_Click()
'Increment i by 1 with each click and show the corresponding item from the
array in the text box
'Test to determine if we have reached the end of the array.
If i < UBound(myarray) Then
i = i + 1
Else
MsgBox "You have reached the end of the Array."
Exit Sub
End If
TextBox1.Text = myarray(i)
End Sub


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
P

Provart

Doug Robbins - Word MVP said:
Like this
Option Explicit
Dim i As Long
Dim myarray As Variant
Private Sub CommandButton1_Click()
'Create the array and show the first item in the Text Box
i = 0
myarray = Split("one\two\three\four\five\six\seven\eight\nine", "\")
TextBox1.Text = myarray(i)
End Sub

Private Sub CommandButton2_Click()
'Increment i by 1 with each click and show the corresponding item from the
array in the text box
'Test to determine if we have reached the end of the array.
If i < UBound(myarray) Then
i = i + 1
Else
MsgBox "You have reached the end of the Array."
Exit Sub
End If
TextBox1.Text = myarray(i)
End Sub


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
Tnx for your help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top