×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

VB : Problem with loops

VB : Problem with loops

VB : Problem with loops

(OP)
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 ?

RE: VB : Problem with loops

If you setup the arrays with the correct syntax then it should be

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

RE: VB : Problem with loops

VB commonly used software? are you kidding, ever heard of Borlands Delphi? That is the evolution of turbo pascal for windows. Check out www.borland.com/delphi 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

RE: VB : Problem with loops

(OP)
Stipity,
I tried it, doesn't work.

svanels,
Delphi 7 is equivalent to Turbo Pascal ?

RE: VB : Problem with loops

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 www.tek-tips.com in the Delphi and Pascal forums.

Best regards



Steven van Els
SAvanEls@cq-link.sr

RE: VB : Problem with loops

(OP)
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 !

RE: VB : Problem with loops

BDE I guess, is the Borland Database Engine, with this you can connect to (windows) databases, msaccess, paradox, oracle, sql-server etc..
How did you feel when starting with VB?


Here is a link with some on-line tutorials for beginners

http://www.delphi.about.com/library/weekly/aa020202a.htm


Send me your e-mail address so we can discuss things better.

Regards

Steven van Els
SAvanEls@cq-link.sr

RE: VB : Problem with loops

>>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


RE: VB : Problem with loops

(OP)
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 !

RE: VB : Problem with loops

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources