Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB : Problem with loops

Status
Not open for further replies.

abbver98

Mechanical
Jun 21, 2002
195
0
0
BE
Many years I used a turbo pascal, Fortran as program software. As VB is the commonly used software now, I try to do some application with it. I find all what I learned in the others program, but in the beginning it seems for me to be hard to success my first application. In fact, my application begins by getting a list of number and compare them to another list, and each time one element of getting list equal to giving list the text of the label display 1.
Getting and displaying the list : I have labels named num1, …num10.Progressively, I entered the list, numi displays the number i of the list. And if this number is equal to one of the getting list, the label text Ri will display 1. My problem is that Vb doesn't recognize this loop :

For i=1 to 10
If numi.text = S then Ri.text = 1
Next i

Can help ?
 
Replies continue below

Recommended for you

VB commonly used software? are you kidding, ever heard of Borlands Delphi? That is the evolution of turbo pascal for windows. Check out If you are familiar with structured programming in fortran and tp, it is a waste of time to use VB.

Regards Steven van Els
SAvanEls@cq-link.sr
 
Much better, I think the last turbo pascal7 was delivered somewhere in 1994 after that Borland changed the name to Delphi, to make a framework for building windows applications. In other words all the nifty windows gadgets like textboxes, treeviews, ocx or ActiveX are available in Delphi, without the so called *.dll problems in VB.
All is compiled in an executable file without the need to distribute dll's. This at the famous turbo pascal speed.
If you are familiar with units in TP, delphi must be no problem at all. Delphi 7 was released recently, so we talk about roughly 8 years of improvement from the dos based Turbo Pascal.
Did you know you can embed the mathcad engine in a Delphi program, or the autocad dwf viewer?
If you want to know more, join us at in the Delphi and Pascal forums.

Best regards



Steven van Els
SAvanEls@cq-link.sr
 
Svanels,

I downloaded the Deldhi7 (It takes 5 hours!). They say that 'let say ' trial version for which they send the key "number" and is supposed to be used without problem. When installing, I was obliged to re-registered. What is this game ?
I tried to run some installed programs (BCDE, ...), I don't understand their utility.
I think that it is far of the level of the reliable programme Turbo Pascal. It's my first impression ! I'm frustrated !
In stead of to make it easy, they complicated the matter !

 
>>If num(i).text = S then R(i).text = 1


Is 'S' a predefined variable? (Dim S as string ?)
the .text properties of textboxes allow only text.

the "R(i).text" above sounds like a control array,
(an array of similarly named controls), is it?

If so, you cant assign a number (=1) to a text box...
you can assign a STRING variable that is "1"...


If num(i).text = "S" then R(i).text = "1"

hope this helps


 
I fixed S to 14 to see if it worked, but it doesn't !
I defined S as a function and add define it; doesn't work !
I defined this loop as a procedure and add define it; doesn't work !
I have defined textboxes Ri (i=1 to 14). How can can apply this loop : For i=1 to 14 is numi.text = 14 then Ri.text = 14 next i.
I don't know how it can be resolved !
 
Set up an array of labels num(1) to num(10)
Do this by adding a textbox to a new form, renaming the textbox to num, then copy and paste that box back into the form. VB asks if yopu want an array - answer yes. Repeat pasting till you have your 10 boxes. They will be on top of each other, so drag them to where you want them. Repeat for the other array R(0) to R(9)
Then Refer to them as num(0) to num(9) as arrays are generally 0 based in VB
Then you loop will look like :
For i = 0 to 9
If num(i).text = 14 then r(1) = 14

VB will take care of assigning a number to a string

Let me know if this helps
 
Status
Not open for further replies.
Back
Top