top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is the use of redim statement in vbscript?

+2 votes
357 views
What is the use of redim statement in vbscript?
posted May 14, 2014 by Amarvansh

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

ReDim statement is used when we use dynamic array. i.e. to define size of an array dynamically. If you want to preserve the previously added elements in an array, you can use keyword preserve.

Using ReDim statement we can change the size of an array in VBScript.I have given you example how to use ReDim.
Example:
Suppose you declare an array Dim Clients(50) Now if you want to change the size of client than you can perform this

Task with the help of ReDim Like that:

ReDim Customers(70)
answer May 15, 2014 by Mishthy Mukherjee
Similar Questions
+1 vote
0 votes

Data file look:-
6 invoices. Each line represent 1 invoice data. Each column separated by | pipe.

7031982|BALANCE|000000 rent on 23/03/2019|0768|110241|385272|PETTY CASH OLAYAN|VENDOR|BPV2019-3|
7031986|BALANCE|000000|0768|226005|388883|\NOMAN\12\as\|EMPLOYEE|BPV2019-377|
7031986|BALANCE|000000|0768|226011|388883| NOMAN|EMPLOYEE|BPV2019-377|
7031986|BALANCE|000000|0768|240007|388883| NOMAN|EMPLOYEE|BPV2019-377|
7032003|BALANCE|000000|0703|231085|384173|WATER COMPANY|VENDOR|BPV2|
7032003|BALANCE|033511|0768|503000|384173|WäTER COMPANY|VENDOR|BPV2|

Requirement:- I need a bat file which will correct existing file

Some times we get the data like:-
1. |1797 \krv\Fice\AP\klo|
==> this should convert like || (just removing complete data within |)
2. |\krv\Finance\Finance\ap\INS12O|
==> this should convert like || (just removing complete data within |)
3. |\as\sa\1\as\|
==> this should convert like || (just removing complete data within |)
4. |second rent at cal on 23/05/2019|
==> this should convert like |second rent at cal on 23-05-2019| (just replace / with - )
5. | Johannes Märkl Monatsrechnung|
==> this should convert like | Johannes Markl Monatsrechnung | (just replace ä with a )

below is code

    @echo off
setlocal enabledelayedexpansion

(for /f "delims=" %%a in (a30077889.txt) do (
  set "line=%%a"
  set "newline="
  for %%b in ("!line:|=" "!") do (
    set "token=%%~b"
    if "!token:~0,1!"=="\" (
     set "newline=!newline!|"
    ) else (
      set "newline=!newline!%%~b|"
    )
  )
  echo !newline:~0,-1!
))>a.new
REM move /y a.new a30077889.txt
...