 |
 |

09-20-2005, 12:48 PM
|
|
Junior Contributor
|
|
Join Date: Sep 2005
Posts: 228
|
|
Indexing TB Problem
|
So i have 50 textboxes in an array... Im trying to make a textbox hidden if it has text in it, then show the next box. This is the code i have, but its not working properly.
Code:
Private Sub Command1_Click()
Dim x As Integer
If Text1(x) = "" Then
lblblah = "k"
Else
Text1(x).Visible = False
Text1(x).Text = Text1(x) + 1
Text1(x).Visible = True
End If
End Sub
Any help would be phenomenal! Thanks
|
|

09-20-2005, 12:58 PM
|
 |
Junior Contributor
|
|
Join Date: Apr 2005
Posts: 397
|
|
here's an example that finds the first empty textbox and sets the focus to it and makes all the other textboxes invisible. Hopefully you can extrapolate from here what you need:
Code:
Dim I as integer
dim firstEmptyBox as integer
firstEmptyBox = -1
'say the array is of textboxes called text1 and the index ranges
'from 0 to 10
for i = 0 to 10
if text1(i).text = "" and firstEmptyBox = -1 then
firstEmptyBox = i
else
text1(i).visible = false
endif
next i
if firstEmptyBox <> -1 then
text1(firstEmptyBox).setfocus
else
'All boxes have text
endif
|
Last edited by BobThePenguin; 09-20-2005 at 01:04 PM.
|

09-20-2005, 01:29 PM
|
|
Junior Contributor
|
|
Join Date: Sep 2005
Posts: 228
|
|
Ok bro i got that to work, and i didnt want to ask you unless i couldnt figure it out, but i cant haha... how would i make label1 display whats in each text box starting with 0, and if a textbox is empty, go back to start point 0.
Code:
Private Sub Command2_Click()
Dim x As Integer
For x = 0 To 49
Label1 = Text1(x).Text
Next x
End Sub
i tried that looking at your first code, and couldnt get it to work. tried a few variations. thank you.
|
|

09-20-2005, 01:45 PM
|
 |
Junior Contributor
|
|
Join Date: Apr 2005
Posts: 397
|
|
So you want a label to display the text in each box as you cycle through them (better put a timer in to slow it down so you can read the text in the label) and, when it gets to an empty textbox then just stop and display the text of text(0)?
Code:
Dim I as integer
dim TheTextBoxIWant as integer
TheTextBoxIWant = -1
for i = 0 to 49
label.caption = text(i).text
'put in a timer or something to make things readable if that is your intent
if text(i).text = "" then 'or whatever stoping conditions you want
TheTextBoxIWant = i
label.caption = text(0).text
exit for
endif
next i
'Now TheTextBoxIWant has the first empty textbox and label has the caption of text(0).text
Is that what you want?? I kinda doubt it is and think this may be closer:
Code:
Dim I as integer
dim flag as boolean
do while flag = false
for i = 0 to 49
if text(i).text = "" then
exit for
endif
label.caption = text(i).text
if i = 49 then flag = true
next i
loop
But since that will loop endlessly if there is an empty textbox you'll need to modify it somehow.
I'm not really sure exactly what you were asking so if neither of these examples help re-phrase your question or provide more details.
|
|

09-20-2005, 01:50 PM
|
|
Junior Contributor
|
|
Join Date: Sep 2005
Posts: 228
|
|
|
those look right, i havent checked them yet.. what i want is this:
The first code you gave me, is basically saving all the info in each text box, then displaying a blank textbox correct?
So now i have a command2, i want to start with the first textbox with info in it, and display that into label 1. Then once thats displayed, they click the command button again, and the second text box with info in it will be displayed in label1.. so on..
|
|

09-20-2005, 01:53 PM
|
 |
Web Junkie
Retired Moderator * Expert *
|
|
Join Date: Apr 2004
Location: D/FW, Texas, USA
Posts: 8,393
|
|
|
Can you post some of the code you've tried? As much as we like to help here, we're not a group that just does custom code for you. We're here to help you learn.
|
__________________
-- wayne, MSSM Retired
> SELECT * FROM users WHERE clue > 0
0 rows returned
|

09-20-2005, 02:02 PM
|
 |
Junior Contributor
|
|
Join Date: Apr 2005
Posts: 397
|
|
Quote:
|
Originally Posted by Mystery
The first code you gave me, is basically saving all the info in each text box
|
No, its not saving anything. Its just turing everything that isnt the first textbox with no text invisible. (wow, thats a lot of negatives especially if you replace invisible with not visible)
Ah, ok.
Code:
Private Sub Command2_Click()
Static FirstEmptyTextBox as Integer 'static means the variable sticks around after the sub is done
'FirstEmptyBox1 = 0 Dont need this, numeric values default to 0
' and we want to keep a running count of where we are
if text1(firstEmptyTextBox).text <> "" and FirstEmptyTextBox <> 50 then
'make sure we aren't going to go off the bounds of the array
''
Label1.caption = Text1(FirstEmptyBox).Text 'So far I have specified what I am doing with every object and you havent specified with any.
'Not that it matters here but it is good practice not to rely on default values
'edit: whoops, see that you did with the textboxes which is good
FirstEmptyTextBox = FirstEmptyTextBox + 1
else
firstEmptyTextBox = 0 'start over if this is a blank textbox
endif
End Sub
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Hybrid Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|
|
|
 |
|