473,419 Members | 1,570 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,419 software developers and data experts.

end loop


on my inbox below i want the loop to quit if the user enters End,

It does not function as written,

any ideas?

thanks

----------------------
Dim inputString As String

Dim i As Integer

For i = 0 To n + 1
farmers(i) = InputBox("enter a farmer's name", , "<farmer>")

If inputString = "end" Then

Exit For

End If

Next

----------------------

Nov 20 '05 #1
8 1464
Murt, you haven't ever assigned a value to inputString - testing the string
for "end" is therefore wasted effort.

If you really must keep the code construct the way you have written it, the
minimal changes required to get your code going have been amended to your
original posting below. I would think of alternative logic such as adding a
new farmer name to an ArrayList until an "end" is detected, then converting
to a String array of farmer.

This is all looks very similiar to a question asked by "portroe" on 02
Friday 2004 ;)

Regards
Hexathioorthooxalate
Dim inputString As String

For i = 0 To n + 1
inputString = InputBox("enter a farmer's name", , "<farmer>")
If inputstring = "end" Then
Exit For
Else farmers(i)=inputstring
End If
Next


"Murt" <mu**@itsschmee.com> wrote in message
news:uj**************@TK2MSFTNGP09.phx.gbl...

on my inbox below i want the loop to quit if the user enters End,

It does not function as written,

any ideas?

thanks

----------------------
Dim inputString As String

Dim i As Integer

For i = 0 To n + 1
farmers(i) = InputBox("enter a farmer's name", , "<farmer>")

If inputString = "end" Then

Exit For

End If

Next

----------------------

Nov 20 '05 #2
You are not assigning anyting to inputString! Instead, you are assigning the
InputBox result to farmers(i)

If inputString = "end" Then

should read

If farmers(i) = "end" Then

I would also suggest using farmers(i).ToLower = "end" to ignore case entered
by user

"Murt" <mu**@itsschmee.com> wrote in message
news:uj**************@TK2MSFTNGP09.phx.gbl...

on my inbox below i want the loop to quit if the user enters End,

It does not function as written,

any ideas?

thanks

----------------------
Dim inputString As String

Dim i As Integer

For i = 0 To n + 1
farmers(i) = InputBox("enter a farmer's name", , "<farmer>")

If inputString = "end" Then

Exit For

End If

Next

----------------------

Nov 20 '05 #3
* Murt <mu**@itsschmee.com> scripsit:
on my inbox below i want the loop to quit if the user enters End,

It does not function as written, [...]

See corrected code below:
----------------------
Dim inputString As String

Dim i As Integer

For i = 0 To n + 1
InputString = InputBox("enter a farmer's name", , "<farmer>")

If inputString = "end" Then

Exit For
Else
Foo(i) = InputString
End If

Next


--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #4
Cor
Hi Herfried,

I find the complete answer from Jim 2 hours before you much better.
(My answer was exaclty the same , inclusief the tolower)

Cor
Nov 20 '05 #5
* "Cor" <no*@non.com> scripsit:
I find the complete answer from Jim 2 hours before you much better.
I find it not as good as mine because it reads "end" into the array
which is not the name of a farmer.
(My answer was exaclty the same , inclusief the tolower)


You didn't post an answer...

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #6
Cor
Hi Murt,

Looking to the answer from Herfried, I think my answer was to him was wrong.

This is a kind of streaming operation and therefore I think that it is right
to do it that way

dim i as integer = 0
farmers(i) = InputBox("enter a farmer's name", , "<farmer>")
do until farmers(i).tolower = "end"
i +=1
farmers(i) = InputBox("enter a farmer's name", , "<farmer>")
loop
i -=1

Cor

Nov 20 '05 #7
Cor
Hi Herfried,

Your answer about the last farmer is right, (could be easily corrected with
a i -= 1, but I think this problem needs another approach, see my answer to
Murt, now your answer would fail because there is no integer n, but that is
of course a not important detail.

Cor
Nov 20 '05 #8
* "Cor" <no*@non.com> scripsit:
Your answer about the last farmer is right, (could be easily corrected with
a i -= 1, but I think this problem needs another approach, see my
answer to


I based my solution on the info the OP gave us/me in his original
thread.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Charles Alexander | last post by:
Hello I am new to php & MySQL - I am trying to retrieve some records from a MySQL table and redisplay them. The data in list form looks like this: Sample_ID Marker_ID Variation ...
2
by: Alex | last post by:
Compiler - Borland C++ 5.6.4 for Win32 Copyright (c) 1993, 2002 Borland Linker - Turbo Incremental Link 5.65 Copyright (c) 1997-2002 Borland Platform - Win32 (XP) Quite by accident I stumbled...
32
by: cj | last post by:
When I'm inside a do while loop sometimes it's necessary to jump out of the loop using exit do. I'm also used to being able to jump back and begin the loop again. Not sure which language my...
2
ADezii
by: ADezii | last post by:
If you are executing a code segment for a fixed number of iterations, always use a For...Next Loop instead of a Do...Loop, since it is significantly faster. Each pass through a Do...Loop that...
15
by: nigelmercier | last post by:
I'm tearing my hair out over a simple for loop! Why does this code work: void clsLCD(void) { // Erase the LCD DDRAM and set cursor home (0,0) char line; for (line=0; line<6; line++)...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.