Creating a For/Next Loop

Question:
I tried using the replace function as shown below, but I receive an error on using “Next i”.

Function formatOutput( theText )Dim iDim sNewStringFor i = 1 to Len(theText)     If Mid(theText, i, 1) <> "’" Then     sNewString = sNewString &  Mid(theText, i, 1)  End IfNext iEnd Function

The error reads: “Expected end of statement”.If I take the i out, I receive a blank output which I’m assuming is because I’ve stopped the loop. What am I doing wrong?
As soon as I can get this working I’d like to try assigning two single quotes as the value of an extra variable to replace all single quotes with two.

Answer:
The Replace function isn’t the issue…Next i is. VBScript does not list the variable following the Next keyword.
Simply remove the i so that the line is just Next, and you’re all set. I typically leave the variable following the Next keyword in a comment, like so:

Next  ’ i

Otherwise, I get confused.

Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

The Latest

your company's audio

4 Areas of Your Company Where Your Audio Really Matters

Your company probably relies on audio more than you realize. Whether you’re creating a spoken text message to a colleague or giving a speech, you want your audio to shine. Otherwise, you could cause avoidable friction points and potentially hurt your brand reputation. For example, let’s say you create a

chrome os developer mode

How to Turn on Chrome OS Developer Mode

Google’s Chrome OS is a popular operating system that is widely used on Chromebooks and other devices. While it is designed to be simple and user-friendly, there are times when users may want to access additional features and functionality. One way to do this is by turning on Chrome OS

homes in the real estate industry

Exploring the Latest Tech Trends Impacting the Real Estate Industry

The real estate industry is changing thanks to the newest technological advancements. These new developments — from blockchain and AI to virtual reality and 3D printing — are poised to change how we buy and sell homes. Real estate brokers, buyers, sellers, wholesale real estate professionals, fix and flippers, and beyond may