User Forms

N

Nev

I have a user form with a series of text boxes txtA txtB to txtZ
I have a series of routines to interchange data betwwen the text boxes
and an array,
e.g
vaData(1, 7) = txtA
vaData(1, 8) = txtB
vaData(1, 9) = txtC
vaData(1, 10) = txtD
vaData(1, 11) = txtE
vaData(1, 12) = txtF
vaData(1, 13) = txtG
how can I creat a loop to cycle through the text boxes?

nev
 
R

Robin Hammond

Nev,

Something like this. I haven't tested it live but it should give you the
idea.

Dim nCounter as integer

With MyForm
for nCounter = 65 to 90
vaData(1,nCounter-58) = .Controls("txt" & Chr(nCounter)).Text
next nCounter
End With

Robin Hammond
www.enhanceddatasystems.com
Check out our XspandXL add-in
 
N

Nev

Thanks Mark works fine, have three other similar situations -

If txtA.Value = "" Then
txtA.Value = 0
Else
txtValue = CDbl(txtA)
End If

If txtB.Value = "" Then
txtB.Value = 0
txtB.Value = CDbl(txtB)
End If
____________________________________________________
If txtA = 0 Then
vaData(1, 7) = Null
Else
vaData(1, 7) = txtA.Value
End If

If txtB = 0 Then
vaData(1, 8) = Null
Else
vaData(1, 8) = txtB.Value
End If

___________________________________________________

Private Sub txtA_Exit(ByVal Cancel As MSForms.ReturnBoolean)
ReCalc
End Sub
Private Sub txtB_Exit(ByVal Cancel As MSForms.ReturnBoolean)
ReCalc
End Sub

Private Sub txtC_Exit(ByVal Cancel As MSForms.ReturnBoolean)
ReCalc
End Sub

all cycle through a to z

any help appreciared
 
M

mjbigelow

See revised code below. Sorry for the delay! Let me know if you have
any questions or it doesn't work.

Mark
 

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