|
-
Feb 9th, 2006, 09:05 PM
#1
Thread Starter
Lively Member
[RESOLVED] exchange text values in an text box array
I wanted to exchange the text values of two text boxes in an array of 10 textboxes. I have tried writing the two texts to textboxes and then reading the opposite textbox, but that didn't work. Does anybody know how to do this? Thanks.
Last edited by A-D-D-F_Toxic; Feb 26th, 2006 at 04:46 PM.
Reason: More specific title
-
Feb 9th, 2006, 09:20 PM
#2
Re: exchange text values in an array
We need more information. What have you tried? Post some code, and tell us what isn't working, and/or any errors that you are getting, including what line the error is on.
-
Feb 9th, 2006, 09:30 PM
#3
Thread Starter
Lively Member
Re: exchange text values in an array
Yeah, good point. I have tried what I said I have tried, but I have also tried something like that, but putting the text in an array and taking the opposite. The method in my first post worked for list indexes of combo boxes. Now, what it does. I try exchanging the text of index 0 and 1, but what happens is very strange. I must have deleted my code when I realized that it wasn't working or something, because nothing happens now. But what I think happened earlier (I don't quite remember, it's been a while) is that index 4 got the text of index 5 and index 5's text was blank. These textboxes are on a different form than the exchange code is, too. No errors occur though.
-
Feb 9th, 2006, 10:15 PM
#4
Re: exchange text values in an array
Take a look at this. Add txt(0), txt(1), and a command button.
VB Code:
Option Explicit
Dim str As String
Private Sub Command1_Click()
str = txt(0).Text
txt(0) = txt(1).Text
txt(1) = str
End Sub
Private Sub Form_Load()
txt(0).Text = "here"
txt(1).Text = "there"
End Sub
-
Feb 9th, 2006, 10:33 PM
#5
Thread Starter
Lively Member
Re: exchange text values in an array
Wow! That's a good method by just sending the one text straight over. I'd love to try this and see if it finally works, but I'm out of time now, so I'll finish when I get a chance and tell you if you helped me.
-
Feb 10th, 2006, 08:45 PM
#6
Thread Starter
Lively Member
Re: exchange text values in an array
Still, nothing happening. This is very strange. Since I have 10 textboxes and the user choses which to exchange the text value of, I have to have a bunch of if's to check which indexes to swith for each of those 3 lines. Maybe I am doing something wrong here.
-
Feb 26th, 2006, 05:05 PM
#7
Thread Starter
Lively Member
Re: exchange text values in an text box array
More details:
I have two combo boxes listing the text boxes from the array. The first combo box is, in dglienna's example, selecting the txt(0) to use. The second combo is txt(1). The array is on a different form than the combo boxes that let you select the text boxes. Since it is on a different form, it could possibly be unloaded. I have created a backup procedure where all my text collects in strings when the form unloads and is taken from the strings when the form loads. The strings (in an array) are cleared after. It works. Because it recovers when the form loads, I made the form load and hide while exchanging the text. Here's my code:
In General Declarations:
VB Code:
Option Explicit
Dim intExchangeLI As Integer
Dim intWithLI
Dim DetailsExchange As String
In my DetailsExchange Procedure (A Public Sub):
VB Code:
frmDetails.Show
intExchangeLI = cboExchange.ListIndex
intWithLI = cboWith.ListIndex
DetailsExchange = frmDetails.txtDetails(intExchangeLI)
frmDetails.txtDetails(intExchangeLI).Text = frmDetails.txtDetails(intWithLI).Text
frmDetails.txtDetails(intWithLI).Text = DetailsExchange
frmDetails.Hide
I used "Exchange" for any name about the first text box in the exchange. I used "With" for any name about the second text box in the exchange.
Last edited by A-D-D-F_Toxic; Feb 26th, 2006 at 05:10 PM.
Reason: Didn't mean to post
-
Feb 26th, 2006, 05:33 PM
#8
Hyperactive Member
Re: exchange text values in an text box array
The options to choose from the comboboxes are the number of the textboxes to exchange or the content of those boxes?
if the options are the numbers then use this:
VB Code:
Option Explicit
Dim str As String
Private Sub Command1_Click()
str = txt(combo1.text - 1).Text
txt(combo1.text - 1) = txt(combo2.text - 1).Text
txt(combo2.text - 1) = str
End Sub
Last edited by Kanbei; Feb 26th, 2006 at 05:40 PM.
-
Feb 26th, 2006, 05:50 PM
#9
Thread Starter
Lively Member
Re: exchange text values in an text box array
The text box selected is the list index from the combo boxes selected, so actually it's none of the above, answering your question. Now, to try this, it would be the same thing, but just "ListIndex" not "Text". Let me try that.
-------------------------------------I try----------------------------------------
It's still not working. I even tried it with "Text" like you put, not "List Index."
-
Feb 26th, 2006, 10:54 PM
#10
Addicted Member
Re: exchange text values in an text box array
Ok so you got 10 textboxs all a array on form1 and 2 combo box's on form2.
Cant you just do something like this on a command button on the first form
VB Code:
Private Sub Command1_Click()
Form2.Show
Me.Hide
End Sub
Loading up form2 and just hiding form1.
Then for form2 put this in it
VB Code:
Private Sub Command1_Click()
Dim strTxt As String
strTxt = Form1.Text1(Combo1.ListIndex)
Form1.Text1(Combo1.ListIndex) = Form1.Text1(Combo2.ListIndex)
Form1.Text1(Combo2.ListIndex) = strTxt
Form1.Show
Unload Me
End Sub
Private Sub Form_Load()
For i = 0 To 9
Combo1.AddItem i
Combo2.AddItem i
Next i
End Sub
This should work, but are you sure none of the other codes work because they all looked fine to me. Also if these all dont work could you post some more code or post the project that you trying to do?
Are we alive or just breathing?
-
Feb 27th, 2006, 09:39 AM
#11
Thread Starter
Lively Member
Re: exchange text values in an text box array
Yes, that's what I have: 10 texts on Form1, and 2 combos on Form2. The first code that I got from David did work in it's own application, but not in mine. I have the button to open Form2 (combo boxes) on another form (I only hide this third form). When the exchange is done, it goes back to the third form. There are also list indexes that I exchange on that form (It works). The second form might hide, if the user selects close when they close it, it hides. The user might select the "x" instead, though, which unloads the form. Your way works in a seperate program, too, but not in mine. I am not ready to post my project, but maybe my little extra explanations here about what you seem to not understand will help.
But here's some more code. Here's in my Public Sub Exchange() Sub. This is to exchange the list indexes on the third form that I was talking about:
VB Code:
'If Details are being moved, then call
If chkMoveDetails.Value = True Then
Call MoveDetails
ElseIf chkMoveDetails.Value = False Then
'Take no effect
End If
I only want the textboxes (details) exchanging if the user has checked a checkbox checked (It's called chkMoveDetails).
VB Code:
Public Sub MoveDetails()
Dim DetailsExchangeSpace As String
frmDetails.Show
frmDetails.txtDetails(0).Visible = True
frmDetails.txtDetails(1).Visible = True
frmDetails.txtDetails(2).Visible = True
frmDetails.txtDetails(3).Visible = True
frmDetails.txtDetails(4).Visible = True
frmDetails.txtDetails(5).Visible = True
frmDetails.txtDetails(6).Visible = True
frmDetails.txtDetails(7).Visible = True
frmDetails.txtDetails(8).Visible = True
frmDetails.txtDetails(9).Visible = True
frmDetails.Hide
DetailsExchange = frmDetails.txtDetails(cboExchange.ListIndex)
frmDetails.txtDetails(cboExchange.ListIndex) = txtDetails(cboExchange.ListIndex)
frmDetails.txtDetails(cboWith.ListIndex) = DetailsExchange
End Sub
frmDetails is the form with my textbox array on it. txtDetails is the textbox array.
-
Feb 27th, 2006, 10:19 AM
#12
Hyperactive Member
Re: exchange text values in an text box array
i still don't get a few thing: why do you say the code is ok but not in YOUR program? something related with if the forms are loaded?
anyways i think in that text you meant to say that you don't want the form to unload when the user presses X.
If so then do this:
VB Code:
Private Sub FORMNAME_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Cancel = True
Me.Hide
End Sub
Query Unload fires before the form unloads, ALWAYS. If at the end of the sub Cancel = True then it doesnt unload.
So here the form will hide.
-
Feb 27th, 2006, 05:49 PM
#13
Thread Starter
Lively Member
Re: exchange text values in an text box array
Well, that probably would work, but that's not what I was asking. I actually didn't know you could make it not unload on X_Click. What I meant by "It works in seperate program but not mine" is I have created a new project and put the code in that have been supplied to me. I tried it and it works, so I try it in the program that I'm making that I want to use the code in and it works. Still not working...very strange. Another thing that I did wrong, that I noticed before I tried this is I have two different string names. I dimed the string as "DetailsExchangeSpace" but wrote and read it as "DetailsExchange" and this is fixed now.
It now looks something more like this:
VB Code:
'...Part of code here is unimportant and not shown here.
'If Details are being moved, then call
If chkMoveDetails.Value = True Then
Call MoveDetails
ElseIf chkMoveDetails.Value = False Then
'Take no effect
End If
'...Part of code here is unimportant and not shown here.
Public Sub MoveDetails()
Dim DetailsExchangeSpace As String
DetailsExchangeSpace = frmDetails.txtDetails(cboExchange.ListIndex)
frmDetails.txtDetails(cboExchange.ListIndex) = txtDetails(cboExchange.ListIndex)
frmDetails.txtDetails(cboWith.ListIndex) = DetailsExchangeSpace
DetailsExchangeSpace = ""
End Sub
Another thing that I did was cleared the string after.
-
Feb 27th, 2006, 07:37 PM
#14
Hyperactive Member
Re: exchange text values in an text box array
i think this line:
frmDetails.txtDetails(cboExchange.ListIndex) = txtDetails(cboExchange.ListIndex)
should be like this:
frmDetails.txtDetails(cboExchange.ListIndex) = txtDetails(cboWith.ListIndex)
maybe that's it, but if have mroe problems tell me plz what results you get: an error? nothing happens?
-
Feb 27th, 2006, 08:24 PM
#15
Thread Starter
Lively Member
Re: exchange text values in an text box array
LOL, whoops! You're right, I wrote the wrong name again. I fixed that and it's still not working (Nothing happens). I looked at the code that you just typed for me to tell me where my mistake was, and noticed that I didn't specify a form on the second txtDetails. So I fixed that little problem, and still nothing happens. Like usual.
-
Feb 28th, 2006, 01:49 PM
#16
Hyperactive Member
Re: exchange text values in an text box array
weird... it isnt a very complicated code... dunnow whats wrong
u sure all names are correct?
post all the button's code.
meanwhile my advice for you to find out yourself:
save that code it a word file and start over but do it in parts.
first just make one text go to another.
then assign the text content to a var and put it in a msgbox.
and so on... maybe this way you'll find out WHAT PART of the code is wrong or missing something
-
Feb 28th, 2006, 05:55 PM
#17
Thread Starter
Lively Member
Re: exchange text values in an text box array
Interesting advice.
Code (I'm not posting all code in the program, that's lots):
Important frmDetails Code:
VB Code:
Private Sub mnuFileClose_Click()
Me.Hide
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Cancel = True
Me.Hide
frmMain.Show
End Sub
All frmMove code:
VB Code:
Option Explicit
Private Sub cmdCancel_Click()
cboExchange.ListIndex = -1
cboWith.ListIndex = -1
Me.Hide
End Sub
Private Sub cmdOk_Click()
If cboExchange.ListIndex = cboWith.ListIndex Then
MsgBox "Please select two seperate list items", , "Sorry!"
ElseIf cboExchange.ListIndex = -1 Then
MsgBox "Please select a list item to exchange.", , "Sorry!"
ElseIf cboWith.ListIndex = -1 Then
MsgBox "Please select a list item to exchange.", , "Sorry!"
Else
cboExchange.Enabled = False
cboWith.Enabled = False
Call Exchange
End If
End Sub
Public Sub Exchange()
'Insert listindex's into Exchange1
If cboExchange.ListIndex = 0 Then
frmExchangeSpace.txtExchange1.Text = frmMain.cboOption1.ListIndex
ElseIf cboExchange.ListIndex = 1 Then
frmExchangeSpace.txtExchange1.Text = frmMain.cboOption2.ListIndex
ElseIf cboExchange.ListIndex = 2 Then
frmExchangeSpace.txtExchange1.Text = frmMain.cboOption3.ListIndex
ElseIf cboExchange.ListIndex = 3 Then
frmExchangeSpace.txtExchange1.Text = frmMain.cboOption4.ListIndex
ElseIf cboExchange.ListIndex = 4 Then
frmExchangeSpace.txtExchange1.Text = frmMain.cboOption5.ListIndex
ElseIf cboExchange.ListIndex = 5 Then
frmExchangeSpace.txtExchange1.Text = frmMain.cboOption6.ListIndex
ElseIf cboExchange.ListIndex = 6 Then
frmExchangeSpace.txtExchange1.Text = frmMain.cboOption7.ListIndex
ElseIf cboExchange.ListIndex = 7 Then
frmExchangeSpace.txtExchange1.Text = frmMain.cboOption8.ListIndex
ElseIf cboExchange.ListIndex = 8 Then
frmExchangeSpace.txtExchange1.Text = frmMain.cboOption9.ListIndex
ElseIf cboExchange.ListIndex = 9 Then
frmExchangeSpace.txtExchange1.Text = frmMain.cboOption10.ListIndex
End If
'Insert listindex's into Exchange2
If cboWith.ListIndex = 0 Then
frmExchangeSpace.txtExchange2.Text = frmMain.cboOption1.ListIndex
ElseIf cboWith.ListIndex = 1 Then
frmExchangeSpace.txtExchange2.Text = frmMain.cboOption2.ListIndex
ElseIf cboWith.ListIndex = 2 Then
frmExchangeSpace.txtExchange2.Text = frmMain.cboOption3.ListIndex
ElseIf cboWith.ListIndex = 3 Then
frmExchangeSpace.txtExchange2.Text = frmMain.cboOption4.ListIndex
ElseIf cboWith.ListIndex = 4 Then
frmExchangeSpace.txtExchange2.Text = frmMain.cboOption5.ListIndex
ElseIf cboWith.ListIndex = 5 Then
frmExchangeSpace.txtExchange2.Text = frmMain.cboOption6.ListIndex
ElseIf cboWith.ListIndex = 6 Then
frmExchangeSpace.txtExchange2.Text = frmMain.cboOption7.ListIndex
ElseIf cboWith.ListIndex = 7 Then
frmExchangeSpace.txtExchange2.Text = frmMain.cboOption8.ListIndex
ElseIf cboWith.ListIndex = 8 Then
frmExchangeSpace.txtExchange2.Text = frmMain.cboOption9.ListIndex
ElseIf cboWith.ListIndex = 9 Then
frmExchangeSpace.txtExchange2.Text = frmMain.cboOption10.ListIndex
End If
'Read Exchange2
If cboExchange.ListIndex = 0 Then
frmMain.cboOption1.ListIndex = Val(frmExchangeSpace.txtExchange2.Text)
ElseIf cboExchange.ListIndex = 1 Then
frmMain.cboOption2.ListIndex = Val(frmExchangeSpace.txtExchange2.Text)
ElseIf cboExchange.ListIndex = 2 Then
frmMain.cboOption3.ListIndex = Val(frmExchangeSpace.txtExchange2.Text)
ElseIf cboExchange.ListIndex = 3 Then
frmMain.cboOption4.ListIndex = Val(frmExchangeSpace.txtExchange2.Text)
ElseIf cboExchange.ListIndex = 4 Then
frmMain.cboOption5.ListIndex = Val(frmExchangeSpace.txtExchange2.Text)
ElseIf cboExchange.ListIndex = 5 Then
frmMain.cboOption6.ListIndex = Val(frmExchangeSpace.txtExchange2.Text)
ElseIf cboExchange.ListIndex = 6 Then
frmMain.cboOption7.ListIndex = Val(frmExchangeSpace.txtExchange2.Text)
ElseIf cboExchange.ListIndex = 7 Then
frmMain.cboOption8.ListIndex = Val(frmExchangeSpace.txtExchange2.Text)
ElseIf cboExchange.ListIndex = 8 Then
frmMain.cboOption9.ListIndex = Val(frmExchangeSpace.txtExchange2.Text)
ElseIf cboExchange.ListIndex = 9 Then
frmMain.cboOption10.ListIndex = Val(frmExchangeSpace.txtExchange2.Text)
End If
'Read Exchange1
If cboWith.ListIndex = 0 Then
frmMain.cboOption1.ListIndex = Val(frmExchangeSpace.txtExchange1.Text)
ElseIf cboWith.ListIndex = 1 Then
frmMain.cboOption2.ListIndex = Val(frmExchangeSpace.txtExchange1.Text)
ElseIf cboWith.ListIndex = 2 Then
frmMain.cboOption3.ListIndex = Val(frmExchangeSpace.txtExchange1.Text)
ElseIf cboWith.ListIndex = 3 Then
frmMain.cboOption4.ListIndex = Val(frmExchangeSpace.txtExchange1.Text)
ElseIf cboWith.ListIndex = 4 Then
frmMain.cboOption5.ListIndex = Val(frmExchangeSpace.txtExchange1.Text)
ElseIf cboWith.ListIndex = 5 Then
frmMain.cboOption6.ListIndex = Val(frmExchangeSpace.txtExchange1.Text)
ElseIf cboWith.ListIndex = 6 Then
frmMain.cboOption7.ListIndex = Val(frmExchangeSpace.txtExchange1.Text)
ElseIf cboWith.ListIndex = 7 Then
frmMain.cboOption8.ListIndex = Val(frmExchangeSpace.txtExchange1.Text)
ElseIf cboWith.ListIndex = 8 Then
frmMain.cboOption9.ListIndex = Val(frmExchangeSpace.txtExchange1.Text)
ElseIf cboWith.ListIndex = 9 Then
frmMain.cboOption10.ListIndex = Val(frmExchangeSpace.txtExchange1.Text)
End If
'If Details are being moved, then call
If chkMoveDetails.Value = True Then
Call MoveDetails
ElseIf chkMoveDetails.Value = False Then
'Take no effect
End If
'Resume view to normal
frmExchangeSpace.txtExchange1.Text = "" 'Delete exchange space list index's
frmExchangeSpace.txtExchange2.Text = "" 'Delete exchange space list index's
cboExchange.Enabled = True 'This was disabled during the move
cboWith.Enabled = True 'This was disabled during the move
cboExchange.ListIndex = -1 'No item is being moved
cboWith.ListIndex = -1 'No item is being moved
Me.Hide
End Sub
Public Sub MoveDetails()
Dim DetailsExchangeSpace As String
DetailsExchangeSpace = frmDetails.txtDetails(cboExchange.ListIndex)
frmDetails.txtDetails(cboExchange.ListIndex) = frmdetail.txtDetails(cboWith.ListIndex)
frmDetails.txtDetails(cboWith.ListIndex) = DetailsExchangeSpace
DetailsExchangeSpace = ""
End Sub
One thing I know I could've done better is exchangin the list indexes on frmMain, putting it in arrays rather than little text boxes on an unshown form. Also, I set the enabled property to false while moving, just incase somebody decides to get a slow computer and then change the values in the middle of the move and then the move reads something different.
-
Feb 28th, 2006, 11:02 PM
#18
Hyperactive Member
Re: exchange text values in an text box array
that is lot of code...
continuing my prevoius advice: in order to find your problem make your code more clear:
those cboOptionX could be an array of controls, know how to make them?
if you do then for example this long code:
VB Code:
'Insert listindex's into Exchange1
If cboExchange.ListIndex = 0 Then
frmExchangeSpace.txtExchange1.Text = frmMain.cboOption1.ListIndex
ElseIf cboExchange.ListIndex = 1 Then
frmExchangeSpace.txtExchange1.Text = frmMain.cboOption2.ListIndex
ElseIf cboExchange.ListIndex = 2 Then
frmExchangeSpace.txtExchange1.Text = frmMain.cboOption3.ListIndex
ElseIf cboExchange.ListIndex = 3 Then
frmExchangeSpace.txtExchange1.Text = frmMain.cboOption4.ListIndex
ElseIf cboExchange.ListIndex = 4 Then
frmExchangeSpace.txtExchange1.Text = frmMain.cboOption5.ListIndex
ElseIf cboExchange.ListIndex = 5 Then
frmExchangeSpace.txtExchange1.Text = frmMain.cboOption6.ListIndex
ElseIf cboExchange.ListIndex = 6 Then
frmExchangeSpace.txtExchange1.Text = frmMain.cboOption7.ListIndex
ElseIf cboExchange.ListIndex = 7 Then
frmExchangeSpace.txtExchange1.Text = frmMain.cboOption8.ListIndex
ElseIf cboExchange.ListIndex = 8 Then
frmExchangeSpace.txtExchange1.Text = frmMain.cboOption9.ListIndex
ElseIf cboExchange.ListIndex = 9 Then
frmExchangeSpace.txtExchange1.Text = frmMain.cboOption10.ListIndex
End If
could be cut in just this:
VB Code:
frmExchangeSpace.txtExchange1.Text = frmMain.cboOption(cboExchange.ListIndex).ListIndex
i know this wont solve your problem, but one thing i've learnt very well is that in 10 pages of code is harder to find a mistake.
if you turn all that code into 5 lines.... life is easier 
if you dont knwo how to do it tell me and ill write the whole code (it should be a line per "section" of IFs)
-
Feb 28th, 2006, 11:27 PM
#19
Frenzied Member
Re: exchange text values in an text box array
 Originally Posted by Kanbei
that is lot of code...
continuing my prevoius advice: in order to find your problem make your code more clear:
those cboOptionX could be an array of controls, know how to make them?
if you do then for example this long code:
VB Code:
'Insert listindex's into Exchange1
If cboExchange.ListIndex = 0 Then
frmExchangeSpace.txtExchange1.Text = frmMain.cboOption1.ListIndex
ElseIf cboExchange.ListIndex = 1 Then
frmExchangeSpace.txtExchange1.Text = frmMain.cboOption2.ListIndex
ElseIf cboExchange.ListIndex = 2 Then
frmExchangeSpace.txtExchange1.Text = frmMain.cboOption3.ListIndex
ElseIf cboExchange.ListIndex = 3 Then
frmExchangeSpace.txtExchange1.Text = frmMain.cboOption4.ListIndex
ElseIf cboExchange.ListIndex = 4 Then
frmExchangeSpace.txtExchange1.Text = frmMain.cboOption5.ListIndex
ElseIf cboExchange.ListIndex = 5 Then
frmExchangeSpace.txtExchange1.Text = frmMain.cboOption6.ListIndex
ElseIf cboExchange.ListIndex = 6 Then
frmExchangeSpace.txtExchange1.Text = frmMain.cboOption7.ListIndex
ElseIf cboExchange.ListIndex = 7 Then
frmExchangeSpace.txtExchange1.Text = frmMain.cboOption8.ListIndex
ElseIf cboExchange.ListIndex = 8 Then
frmExchangeSpace.txtExchange1.Text = frmMain.cboOption9.ListIndex
ElseIf cboExchange.ListIndex = 9 Then
frmExchangeSpace.txtExchange1.Text = frmMain.cboOption10.ListIndex
End If
could be cut in just this:
VB Code:
frmExchangeSpace.txtExchange1.Text = frmMain.cboOption(cboExchange.ListIndex).ListIndex
i know this wont solve your problem, but one thing i've learnt very well is that in 10 pages of code is harder to find a mistake.
if you turn all that code into 5 lines.... life is easier 
if you dont knwo how to do it tell me and ill write the whole code (it should be a line per "section" of IFs)
you can also use the select case statement to replace the if...elseif......endif statement.
that would in a way give a clearer view of the flow
VB Code:
select case cboExchange.ListIndex
case 1: '<a line of code here>
case 2: '<another line>
'and so on and so forth
end select
On error goto Trap
Trap:
in case of emergency, drop the case...
****************************************
If this post has been resolved. Please mark it as "Resolved" by going through the "Thread Tools" above and clicking on the "Mark Thread Resolved " option. if a post is helpful to you, Please Rate it by clicking on the Rate link right below the avatar
-
Mar 1st, 2006, 09:07 AM
#20
Thread Starter
Lively Member
Re: exchange text values in an text box array
I've used my cboOptions in code so much, that if I put them in an array, I will have to change lots of code that has it already. Like I said already, that part works. The problem is that the DetailsExchange procedure doesn't work.
d3gerald, I am familiar with nothing of your little code except cboExchange.ListIndex.
-
Mar 1st, 2006, 10:12 AM
#21
Hyperactive Member
Re: exchange text values in an text box array
Sorry then i wouldn't know what to tell you, so again my advices:
- Run the program step by step (with F8 you go to the next step) and you can see each var's value in every step.
- Add to your code some msgboxes showing var's and control's values in a precise moment so you see if they have the value you expected
- And again: YOU REALLY SHOULD make those combos an array of control. Suppose you find a mistake now: you would have to correct it in 700 lines.
If you create an array you will have the chance to start from the scratches and probably find the mistake, and if not, when you find the mistake you will correct only a couple of lines.
-
Mar 1st, 2006, 07:38 PM
#22
Thread Starter
Lively Member
Re: exchange text values in an text box array
I forgot about that next step thing.
And if I change them to arrays now, then I have to change 700 lines to array format! I might get it into an array once this is figured out.l
Well, I just opened the project, and apparently I commented something out that the program didn't like, because my frmDetails doesn't work, now.
VB's making me a bit mad right now, and I just ran out of time. I'll see if I can get patient with it sometime later.
-
Apr 3rd, 2006, 08:21 AM
#23
Thread Starter
Lively Member
Re: exchange text values in an text box array
I'm back on the problem again. The problem actually isn't in the code of moving my texts. I commented everything out in the if (it's an if now, not a new sub) of the text moving and put a message box in there. I tried moving the texts and I didn't get the message, so that means that there's something wrong with getting to the procedure.
VB Code:
If chkDetails.Value = True Then
Dim detailsExchangeSpace As String
detailsExchangeSpace = frmDetails.txtDetails(frmExchange.cboExchange(0).ListIndex)
frmDetails.txtDetails(cboExchange(0).ListIndex) = frmDetails.txtDetails(cboExchange(1).ListIndex)
frmDetails.txtDetails(cboExchange(1).ListIndex) = detailsExchangeSpace
End If
I took the message box out of this sample of code. Another thing I changed was "cboExchange" and "cboWith" which are now in an array called "cboExchange."
-
Apr 3rd, 2006, 08:28 AM
#24
Re: exchange text values in an text box array
Try:
VB Code:
If chkDetails.Value = vbChecked Then
-
Apr 3rd, 2006, 04:34 PM
#25
Thread Starter
Lively Member
Re: exchange text values in an text box array
I knew I wasn't understanding the checkboxes "checked" property in code. That worked much better, thanks! Woohoo!
-
Apr 3rd, 2006, 04:58 PM
#26
Re: [RESOLVED] exchange text values in an text box array
BTW, you can shorten all that If...ElseIf code you were using without using a control array:
VB Code:
frmExchangeSpace.txtExchange1.Text = frmMain.Controls("cboOption" & cboExchange.ListIndex).ListIndex
That way you don't need to rename all your controls
-
Apr 3rd, 2006, 05:03 PM
#27
Thread Starter
Lively Member
Re: [RESOLVED] exchange text values in an text box array
I didn't rename it, I'm remaking the whole program...I know it might sound strange, it seemed to screw up more and more with everything I did, so I just redid it...there were lots of things to change, anyway, like that array, which would actually make it easier in lots of places, but thanks for the code.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|