Computer Engineers

 
Home | Computer engineering other top | Fiber / Wireless / Copper Tran | Semiconductor engineering
  Position:HOME>Programming language engineeri>Article Content
VB : Problem with loops
Source:Internet Author:Unknow Pubdate:2008-04-14  
abbver98 (Mechanical) 15 Oct 02 3:42
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 ?


Stipity (Computer) 15 Oct 02 11:51
字串1

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

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



svanels (Petroleum) 15 Oct 02 21:29
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

abbver98 (Mechanical) 16 Oct 02 7:03
Stipity,
I tried it, doesn't work.

svanels,
Delphi 7 is equivalent to Turbo Pascal ?

svanels (Petroleum) 16 Oct 02 7:51
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.

字串9


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

abbver98 (Mechanical) 17 Oct 02 5:24
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. 字串9
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 !



svanels (Petroleum) 17 Oct 02 9:10
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

rocheey (Industrial) 21 Oct 02 12:30
>>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.

字串8



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




abbver98 (Mechanical) 22 Oct 02 10:26
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 !

johnwm (Computer) 22 Oct 02 19:58
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)
字串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


(Click:

Previous:Serial port programming   Next:Can an MSFlexGrid be used with DAO?
[Add TO Favorites] [TOP] [PRINT] [CLOCE WINDOWS]  
  Hot Article
·PIC code for triac light dimme
·Connecting a Footswitch to an
·Siemens s7-200 PLC & Visua
·TETRIS source code is availabl
·XML Files and Terramodel
·controlling GPIB from VBA
·LINKING MSC PATRAN WITH INTRAN
·How to interface RS-485 / Modb
·VBA WITH AB PLC
·SIEMENS: I/O, NCDDE AND DCTL
·getch() function
·Visual Basic Serial Comms To S
  Related Articles
·Can an MSFlexGrid be used with
·How to transfer data through P
·generate exe-files, crowded wi
·Import C to MatLab
·COMport programming
·Modem programming
·random numbers
·Topmost VB form name - active
·WellFlo data file structure/la
·Floting point
·Hide Rows Macro in Excel
·.net Technology
Power by DedeCms