---
title: "Vad är det för fel på While... Wend?"
type: "forum-thread"
url: "https://www.webforum.nu/amne/asp/45548-vad-är-det-för-fel-på-while-wend"
topic: "ASP"
topic_url: "https://www.webforum.nu/amne/asp"
author: "trexter.com"
published: "2002-06-10T10:13:19.000Z"
updated: "2002-06-10T17:48:55.000Z"
replies: 7
views: 382
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/asp/45548-vad-är-det-för-fel-på-while-wend"
---

# Vad är det för fel på While... Wend?

## #1 — trexter.com, 2002-06-10T10:13Z

På w3schools.com står det så här (utan någon förklaring):
"While...Wend statement - Do not use it - use the Do...Loop statement instead "

Varför? Vad är det för fel på att använda detta?!

Permalänk: https://www.webforum.nu/p/45548

## #2 — trexter.com, 2002-06-10T10:16Z

\[Detta står under \[VB-script\]\]

Permalänk: https://www.webforum.nu/p/695081

## #3 — Erik Juhlin, 2002-06-10T10:32Z

Låter lite märkligt. While...Wend ska vara bättre om man ser till prestanda.
Däremot kan man t.ex. inte använda Exit Do som man kan med Do...Loop.

Permalänk: https://www.webforum.nu/p/695096

## #4 — icaaq, 2002-06-10T10:32Z

klippt ur Microsoft.com

> Visual Basic Scripting Edition   
> 
> While...Wend Statement
> Executes a series of statements as long as a given condition is True.
> 
> While condition
>    Version \[statements\]
> Wend
> Arguments
> condition 
> Numeric or string expression that evaluates to True or False. If condition is Null, condition is treated as False. 
> statements 
> One or more statements executed while condition is True. 
> Remarks
> If condition is True, all statements in statements are executed until the Wend statement is encountered. Control then returns to the While statement and condition is again checked. If condition is still True, the process is repeated. If it is not True, execution resumes with the statement following the Wend statement. 
> 
> While...Wend loops can be nested to any level. Each Wend matches the most recent While.
> 
> **Note   The Do...Loop statement provides a more structured and flexible way to perform looping.**
> The following example illustrates use of the While...Wend statement: 
> 
> Dim Counter
> Counter = 0   ' Initialize variable.
> While Counter \< 20   ' Test value of Counter.
>    Counter = Counter + 1   ' Increment Counter.
>    Alert Counter
> Wend   ' End While loop when Counter \> 19.

Permalänk: https://www.webforum.nu/p/695098

## #5 — LarsG, 2002-06-10T10:48Z

> While...Wend ska vara bättre om man ser till prestanda.

Varför?

Permalänk: https://www.webforum.nu/p/695113

## #6 — Erik Juhlin, 2002-06-10T16:33Z

Ingen aning. Bara vad jag hört. :)

Permalänk: https://www.webforum.nu/p/695289

## #7 — doggelito, 2002-06-10T17:07Z

Fortsättning från microsoft:

> Arguments
> condition 
> Numeric or string expression that is True or False. If condition is Null, condition is treated as False. 
> statements 
> One or more statements that are repeated while or until condition is True. 
> Remarks
> The Exit Do can only be used within a Do...Loop control structure to provide an alternate way to exit a Do...Loop. Any number of Exit Do statements may be placed anywhere in the Do...Loop. Often used with the evaluation of some condition (for example, If...Then), Exit Do transfers control to the statement immediately following the Loop. 
> 
> When used within nested Do...Loop statements, Exit Do transfers control to the loop that is nested one level above the loop where it occurs.
> 
> The following examples illustrate use of the Do...Loop statement: 
> 
> Do Until DefResp = vbNo
>    MyNum = Int (6 \* Rnd + 1)   ' Generate a random integer between 1 and 6.
>    DefResp = MsgBox (MyNum & " Do you want another number?", vbYesNo)
> Loop
> 
> Dim Check, Counter
> Check = True: Counter = 0   ' Initialize variables.
> Do                            ' Outer loop.
>    Do While Counter \< 20      ' Inner loop.
>       Counter = Counter + 1   ' Increment Counter.
>       If Counter = 10 Then    ' If condition is True...
>          Check = False        ' set value of flag to False.
>          Exit Do              ' Exit inner loop.
>       End If
>    Loop
> Loop Until Check = False      ' Exit outer loop immediately.

den stora skillnaden är väl att man kan avbryta en do-loop men inte en while-loop och i och med det är do-loopen mer flexibel. :)

Permalänk: https://www.webforum.nu/p/695317

## #8 — LAMP, 2002-06-10T17:48Z

Om man tittar på loopning av recsets så borde både en do loop och en while loop vara hugget som stucket. Den tar en post, skriver ut, går in och hämtar nästa, skriver ut osv ev hämtar den gruppvis. Medan om du loopar ut en array som du hämtat med getrows(), då har du många färre anrop till databasen och getstring() ytterligare färre. Så jag skulle vilja rangordna så här:

1) getstring()
2) getrows(), loopa ut array med for-slinga
3) do loop och while loop

Permalänk: https://www.webforum.nu/p/695351

---

Tråden på webben: https://www.webforum.nu/amne/asp/45548-vad-är-det-för-fel-på-while-wend
