Hey again folks. I have a question. I have searched far and wide for ideas on how to go about coding this. The below image will show you what I am trying to achieve.
How would you all go about coding this? I would like the user to click on the Generate button to achieve the Half Cycles value like in the image.
No idea what that means.
You didnt just paste the code in and run it, did you?
Thats not the name of your listbox
Thats not the variable you have the rownumber in.
And there needs to be an existing row in the listbox to amend if you address the cells individually like this.
If there isnt, then you need to be doing a
mylistbox.addrow "some data"
mylistbox.cell(mylistbox.lastindex,1) = "some data for the second column"
[quote=319613:@Jeff Tullin]When you come back and ask how to put words into the second cell too, I repeat:
(but using your variable names since you dont work well with generic examples)
for i as integer = 1 to total
lbRunList.addrow str(i)
lbRunList.cell(lbRunList.lastindex,1) = "some data for the second column"
next[/quote]
Thank you Jeff.
[quote=319613:@Jeff Tullin]When you come back and ask how to put words into the second cell too, I repeat:
(but using your variable names since you dont work well with generic examples)
dim total as integer = Val(txtHalfCycles.Text)
for i as integer = 1 to total
lbRunList.addrow str(i)
lbRunList.cell(lbRunList.lastindex,1) = "Free Run " + txtWraps.text + " Turn(s)"
next[/quote]
Hi Jeff. I was wondering how to make the above still show all the halfcycles and in the second cell at the top only show by default
“Free Run " + txtWraps.text + " Turn(s)” only in the second cell?
Okay. After reading a few books and doing some searching through the xdev and the sort. I am stuck with this below image shows that the first part of the Generate button works quite well. But I’m getting a repeat of the user input from,
dim total as integer = Val(txtHalfCycles.Text)
for i as integer = 1 to total
lbRunList.addrow str(i)
lbRunList.cell(0,1) = "Free Run For " + txtPartsField.text + " Part(s) " + " X " + txtBightsField.text + " Bight(s) " + txtWraps.text + " - ½ Turn(s) "_
+ "OR " + txtWraps1.Text + " Full Wraps"
lbRunList.Cell(lbRunList.LastIndex, 1) = txtCoding.Text
next
Is the repeats from the str(i)? or something else.
So to explain what’s going on as clearly as I can.
The line below adds a new row to the listbox every time you go through the loop and puts the value of the variable i, as a string, into the first column in the newly added row:
lbRunList.addrow str(i)
This next line of code is setting the value of cell(0,1) to the concatenated string that you are defining here. Since the values of row and column in cell(0,1), which is row 1 column 2, are hard coded, you are actually doing the exact same thing every loop. You should ideally remove this line from the loop and put it after, so that it only runs once.
lbRunList.cell(0,1) = "Free Run For " + txtPartsField.text + " Part(s) " + " X " + txtBightsField.text + " Bight(s) " + txtWraps.text + " - ½ Turn(s) "_
+ "OR " + txtWraps1.Text + " Full Wraps"
The last line of code says to put the value of txtCoding.Text in the second column (column index 1) of the last row (identified by lbRunList.LastIndex). The last row had just been created previously by the lbRunList.addrow method. So each time you go through the loop, this will reference the newly created row in the list box and put the same value into the second column of every row.
So that’s the wordy version of why it’s happening, but without knowing how you intend for the application to function, it’s hard to provide an example that will do exactly what you are looking for.
You are definitely better off understanding what is going on and writing the code yourself. It’s the best way to learn.
I was trying to say that example code will rarely be exactly what you are looking for, but it’s good to use as a functioning starting point on which to expand and implement your own ideas.
I have RealBasic The Definitive Guide. I do look at that a lot. I also have from novice to professional book. that one is not so good. But the definitive guide has been helpful for the most part.