#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default User Forms

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



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 79
Default User Forms

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


"Nev" wrote in message
...
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



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default User Forms

Try this:

For intVar = 1 to 26
vaData(1, intVar) = UserForm1.Controls("txt" & chr(64 + intVar))
Next intVar

Let me know if that doesn't work.

Mark
---
Mark Bigelow
mjbigelow at hotmail dot com
http://hm.imperialoiltx.com

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default User Forms

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



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default User Forms

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

Mark

Nev wrote:
*Thanks Mark works fine, have three other similar situations -

For x = 1 to 26
If UserForm1.Controls("txt" & CHR(64 + x)).Value = "" Then
UserForm1.Controls("txt" & CHR(64 + x)).Value = 0
Else
txtValue = CDbl(UserForm1.Controls("txt" & CHR(64 + x)).Value)
End If
Next x
__________________________________________________ __
For x = 1 to 26
If UserForm1.Controls("txt" & CHR(64 + x)).Value = 0 Then
vaData(1, 7) = Null
Else
vaData(1, 7) = UserForm1.Controls("txt" & CHR(64 + x)).Value
End If
Next x
__________________________________________________ _

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 *




------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
New to User Forms Stacy New Users to Excel 2 July 30th 08 04:26 PM
User Forms Joanne New Users to Excel 18 July 5th 07 12:42 AM
user forms Obi-Wan Kenobi Excel Discussion (Misc queries) 0 March 21st 06 08:28 PM
User Forms Runner77 Excel Discussion (Misc queries) 1 January 12th 06 06:20 AM
user forms Runner77 Excel Discussion (Misc queries) 0 January 12th 06 04:31 AM


All times are GMT +1. The time now is 01:10 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"