473,806 Members | 2,929 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1482
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
Hexathioorthoox alate
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)=inpu tstring
End If
Next


"Murt" <mu**@itsschmee .com> wrote in message
news:uj******** ******@TK2MSFTN GP09.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).ToLo wer = "end" to ignore case entered
by user

"Murt" <mu**@itsschmee .com> wrote in message
news:uj******** ******@TK2MSFTN GP09.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).tolo wer = "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
2944
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 G23_NA17192.fsa rs7374540 A/C I23_Control.fsa rs7374540 C/C
2
2689
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 across some wierd loop behavior. With the pasted code I receive the output that follows. I realize that the code is broken, because the inner loop fails to reset j for each iteration of the outer loop (the fix is commented out). I also know that...
32
2612
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 memories are of but I think I just said loop somewhere inside the loop and it immediately jumped back to the start of the loop and began again. I can't seem to do that in .net. I this functionality available?
2
19318
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 iterates a specified number of times, requires you to also implement or decrement some sort of Loop Counter, while a For...Next Loop does that work for you. Both Loops will provide the same results, but the For...Next Loop is substantially faster. One...
15
2286
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++) // 6 lines of LCD DDRAM {clLLCD(line);} // Erase each in turn }
0
9719
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10620
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10369
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10372
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9187
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7650
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5682
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4329
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3851
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.