1
Write a program to read data from a text file
Set fso =
createobject(“scripting.filesystemobject”)
Set fs = fso.opentextfile(“d:nu.txt”,1,true)
Msgbox fs.readall
2
Write a program to write data into a text file
Set fso = createobject(“scripting.filesystemobject”)
Set fs = fso.opentextfile(“d:nu.txt”,2,true)
Fs.writeline”what ever you want to write
goes here”
3 Write a program to print all lines that contains a word either “infics” or “solutions”
Set fso =
createobject("scripting.filesystemobject")
Set fs =
fso.OpenTextFile("d:nu.txt",1,true)
Do until fs.AtEndOfStream <> 0
s
= fs.ReadLine
If
instr(s,"nokia") Then
msgbox
s
else
msgbox
"word is not present in this line"&" "&s
End
If
Loop
4
Write a program to print the current folder name
5 Write a program to print files in a given folder
5 Write a program to print files in a given folder
Set fso =
createobject("scripting.filesystemobject")
Set fpath = fso.GetFolder("E:\qtp and
vbscript sites")
Set folderz = fpath.files
For each fol in folderz
print fol.name
Next
6 Write a program to print subfolders in a given folder
6 Write a program to print subfolders in a given folder
Set fso =
createobject("scripting.filesystemobject")
Set odrive = fso.Drives
For each d in odrive
print d
Set folderz = fso.GetFolder(d)
Set subfol = folderz.SubFolders
For each fol in subfol
print fol.name
Next
Next
7 Write a program to print all drives in the file system
Set fso =
createobject(“scripting.filesystemobject”)
Set odrive = fso.drives
For each d in odrive
Print d.driveletter
Next
8 Write a program to print current drive name
9 Print the last modified and creation date of a given file
8 Write a program to print current drive name
9 Print the last modified and creation date of a given file
10
Print the size of the file and size on the disk.
11 Write a program to display files of a specific type
12 Write a program to print the free space in a given drive
11 Write a program to display files of a specific type
12 Write a program to print the free space in a given drive
Set fso =
createobject(“scripting.filesystemobject”)
Set odrive = fso.drives
For each d in odrive
Print d.availablespace
Next
13 Write a program to display all subfolders in a given folder
13 Write a program to display all subfolders in a given folder
On error resume next
Set fso =
createobject("scripting.filesystemobject")
Set odrive = fso.Drives
For each d in odrive
print d
print "______________________________________________________________________"
Set folderz = fso.GetFolder(d)
Set subfol = folderz.SubFolders
For each fol in subfol
print fol.name
print
"______________________________________________________________________"
Set filez = fol.files
For each f in filez
print f.name
Next
Next
Next
14 Write a program to find whether a given folder is a special folder
15 Write a program to remove all empty files in the folder
Set fso =
createobject("scripting.filesystemobject")
Set fold =
fso.GetFolder("d:\testfolder")
Set filez = fold.Files
For each f in filez
fsize = f.size
If fsize = 0 Then
f.delete
End If
Next
16 Write a program to Copy contents of one folder to other folder
17 Write a program to check whether a given path represents a file or a folder
18 Write a program to compress a folder
19 Write a program to rename a folder
20 Write program to display all folders created on a specific date
21 Write a Program to enable disk quotas
22 Write a program to create, modify and delete disk quota
23 Write a program to display all files containing “demo” in their name
Set fso =
createobject("scripting.filesystemobject")
Set fold = fso.GetFolder("H:/")
Set folz = fold.subfolders
For each f in folz
Set fname = f.files
For each fs in fname
s = fs.name
If instr(s,"Gangs") Then
print
fs.name
End If
Next
Next
24
Write a program to print all lines in a file that ends with “world”
25 Write a program to check whether string starts with “Error”
26 Write a program to Replace all words that contains “demo” in a file with the word “infics”
25 Write a program to check whether string starts with “Error”
26 Write a program to Replace all words that contains “demo” in a file with the word “infics”
str = "Replace space with tab in between
the words of a string"
replstr = " "
Set oregexp = new regexp
With oregexp
.pattern = " "
.global = true
.ignorecase = true
End With
newstring = oregexp.replace(str,replstr)
msgbox newstring
27 Write a program to check whether a string contains only alpha numerics
Var = “”
28 Write a program to check whether a string is in email format
29 Write a program to check whether given string is in date format
30 Write a program to print all the lines ending with '$'
31 Check whether middle three characters in a word contains alphanumeric
32 Check whether a given line is an empty
33 Write a program to Add elements to a dictionary
34 Write a program to display items in a dictionary
35 Write a program to check whether specified Key exists in a Dictionary
36 Write a program to Store dictionary items in an array
37 Write a program to delete Key Value pair in the dictionary
38 Write a program to monitor operating system performance
39 Write a program to monitor operating system objects
40 Write a program to monitor web server performance
41 Write a program to monitor browser service performance
42 Write a program to list the PID and PPID of a process
43 Write a program to create a registry key
44 Write a program to list registry files
45 Write a program to list registry value and types
46 Write a program to delete registry key
47 Write a program to Stop and Start alerter service
48 Write a program to list services running and their statuses.
49 Write a program to list services that can be stopped
50 Write a program to start auto start services that have stopped
51 Write a program to Invoke command prompt and execute dir command from the
shell
52 Write a program to schedule a task
53 Write a program to list and delete scheduled tasks
54 Write a program to add a local user account
55 Write a program to disable and delete a local user account
56 Write a program to list all user accounts in the local computer
57 Write a program to display logged in user name
58 Write a program to list cache memory information
59 Write a program to list physical memory properties
60 Write a program to list memory devices
61 Write a program to find Hard Disk size
62 Write a program to find RAM size
63 Write a program to restart a computer
64 Write a program to shutdown a computer
65 Write a program to Execute Perl script from VB Script
66 Find the systems present in the LAN
67 Write a program to Print using remote printer
68 Verify whether IE enhanced security is enabled for logged on user
69 Write a program to add a website to a favourite menu
70 Write a program to list IE LAN settings
71 Write a program to list cache, connection and security zone settings
72 Find the arguments passed to a Windows Script Host
73 Write a program to Map a network drive
74 Write a program to Print to the local printer
75 Write a program to Print to remote printer
76 Write a program to Print Computer name
77 Write a program to Print free memory in the drive
78 Write a program to Print memory and CPU utilized by a process
79 Write a program to Find the ipaddress of a local system
80 Write a program to find Network Drives
81 Write a program to find the Full path name of a shortcut
82 Write a program to Retrieve all the rows in a table
83 Write a program to find the name of columns in a table
84 Write a program to find number of rows in each column
85 Write a program to connect and print data from oracle database
86 Write a program to connect and print data from SQL Server database
87 Write a program to retrieve specific field from the database table
88 Write a program to check whether a column in the database is in ascending order
89 Write a program to insert a new row into the database table
90 Write a program to open the two record sets
91 Write a program to Update the specific field in the database table
92 Write a program to delete all records whose username starts with demo
93 Write a program to sort the record set
94 Write a program to find number of rows in a table
95 Write a program to Write simple text to windows word
96 Write a program to Write table to windows word
97 Write a program to apply style to a table in word document
98 Write a program to open and print a word document
99 Write a program to send an email using outlook
100 Write a program to print data present in all sheets of an excel files
28 Write a program to check whether a string is in email format
29 Write a program to check whether given string is in date format
30 Write a program to print all the lines ending with '$'
31 Check whether middle three characters in a word contains alphanumeric
32 Check whether a given line is an empty
33 Write a program to Add elements to a dictionary
34 Write a program to display items in a dictionary
35 Write a program to check whether specified Key exists in a Dictionary
36 Write a program to Store dictionary items in an array
37 Write a program to delete Key Value pair in the dictionary
38 Write a program to monitor operating system performance
39 Write a program to monitor operating system objects
40 Write a program to monitor web server performance
41 Write a program to monitor browser service performance
42 Write a program to list the PID and PPID of a process
43 Write a program to create a registry key
44 Write a program to list registry files
45 Write a program to list registry value and types
46 Write a program to delete registry key
47 Write a program to Stop and Start alerter service
48 Write a program to list services running and their statuses.
49 Write a program to list services that can be stopped
50 Write a program to start auto start services that have stopped
51 Write a program to Invoke command prompt and execute dir command from the
shell
52 Write a program to schedule a task
53 Write a program to list and delete scheduled tasks
54 Write a program to add a local user account
55 Write a program to disable and delete a local user account
56 Write a program to list all user accounts in the local computer
57 Write a program to display logged in user name
58 Write a program to list cache memory information
59 Write a program to list physical memory properties
60 Write a program to list memory devices
61 Write a program to find Hard Disk size
62 Write a program to find RAM size
63 Write a program to restart a computer
64 Write a program to shutdown a computer
65 Write a program to Execute Perl script from VB Script
66 Find the systems present in the LAN
67 Write a program to Print using remote printer
68 Verify whether IE enhanced security is enabled for logged on user
69 Write a program to add a website to a favourite menu
70 Write a program to list IE LAN settings
71 Write a program to list cache, connection and security zone settings
72 Find the arguments passed to a Windows Script Host
73 Write a program to Map a network drive
74 Write a program to Print to the local printer
75 Write a program to Print to remote printer
76 Write a program to Print Computer name
77 Write a program to Print free memory in the drive
78 Write a program to Print memory and CPU utilized by a process
79 Write a program to Find the ipaddress of a local system
80 Write a program to find Network Drives
81 Write a program to find the Full path name of a shortcut
82 Write a program to Retrieve all the rows in a table
83 Write a program to find the name of columns in a table
84 Write a program to find number of rows in each column
85 Write a program to connect and print data from oracle database
86 Write a program to connect and print data from SQL Server database
87 Write a program to retrieve specific field from the database table
88 Write a program to check whether a column in the database is in ascending order
89 Write a program to insert a new row into the database table
90 Write a program to open the two record sets
91 Write a program to Update the specific field in the database table
92 Write a program to delete all records whose username starts with demo
93 Write a program to sort the record set
94 Write a program to find number of rows in a table
95 Write a program to Write simple text to windows word
96 Write a program to Write table to windows word
97 Write a program to apply style to a table in word document
98 Write a program to open and print a word document
99 Write a program to send an email using outlook
100 Write a program to print data present in all sheets of an excel files
1 Print Hello World
2 Find whether given number is a odd number
3 Print odd numbers between given range of numbers
4 Find the factorial of a given number
5 Find the factors of a given number
6 Print prime numbers between given range of numbers
7 Swap 2 numbers with out a temporary variable
2 Find whether given number is a odd number
3 Print odd numbers between given range of numbers
4 Find the factorial of a given number
5 Find the factors of a given number
6 Print prime numbers between given range of numbers
7 Swap 2 numbers with out a temporary variable
a = 2
b = 3
a = a+b
b = a-b
a = a-b
msgbox "value of a is "&a
msgbox "value of b is "&b
8 Write a program to Perform specified Arithmetic Operation on two given
numbers
9 Find the length of a given string
Msgbox Len(str)
10 Reverse given string
Msgbox Strreverse(str)
11 Find how many alpha characters present in a
string.
str = "ca1b2c3d4"
n = len(str)
cnt = 0
For i = 1 to n
If isnumeric((mid(str,i,1))) = false Then
cnt = cnt+1
End If
Next
msgbox cnt
To counting numeric characters present in a
string
str = "ca1b2c3d4"
n = len(str)
cnt = 0
For i = 1 to n
If isnumeric((mid(str,i,1))) Then
cnt = cnt+1
End If
Next
msgbox cnt
12 Find occurrences of a specific character in a string
str = "ca1b2c3d4"
n = len(str)
cnt = 0
For i = 1 to n
If (mid(str,i,1)) = "c" Then
cnt = cnt+1
End If
Next
msgbox cnt
13 Replace space with tab in between the words of a string.
str = "Replace space with tab in between
the words of a string"
replstr = " "
Set oregexp = new regexp
With oregexp
.pattern = " "
.global = true
.ignorecase = true
End With
newstring = oregexp.replace(str,replstr)
msgbox newstring
14 Write a program to return ASCII value of a given character
msgbox asc("A")
15 Write a program to return character corresponding to the given ASCII value
15 Write a program to return character corresponding to the given ASCII value
msgbox Chr(65)
16 Convert string to Upper Case
16 Convert string to Upper Case
msgbox ucase(“string”)
17 Convert string to lower case
Msgbox lcase(“string”)
18 Write a program to Replace a word in a string with another word
18 Write a program to Replace a word in a string with another word
str = "Replace space with tab in between
the words of a string"
replstr = "strings"
Set oregexp = new regexp
With oregexp
.pattern = "string"
.global = true
.ignorecase = true
End With
newstring = oregexp.replace(str,replstr)
msgbox newstring
19 Check whether the string is a POLYNDROM
20 Verify whether given two strings are equal
19 Check whether the string is a POLYNDROM
20 Verify whether given two strings are equal
str1 = "the"
str2 = "the"
msgbox strcomp(str1,str2)
if result is 0 then equal
if result is 0 then equal
21 Print all values from an Array
a
=array("a","b","c")
For each s in a
msgbox s
Next
22 Sort Array elements
23 Add two 3X3 matrices
24 Multiply Two Matrices of size 2X2
25 Convert a String in to an array
26 Convert a String in to an array using ‘I’ as delimiter
27 Find number of words in string
23 Add two 3X3 matrices
24 Multiply Two Matrices of size 2X2
25 Convert a String in to an array
26 Convert a String in to an array using ‘I’ as delimiter
27 Find number of words in string
str = "count how many words in a
string"
s = split(str," ")
'For i = 0 to ubound(s)
'msgbox s(i)
'Next
'msgbox i
msgbox ubound(s)+1
28 Write a program to reverse the words of a
given string.
str = "count how many words in a
string"
s = split(str," ")
For i = ubound(s) to 0 step -1
revstring = revstring&"
"&s(i)
Next
msgbox revstring
29 Print the data as a Pascal triangle
30 Join elements of an array as a string
31 Trim a given string from both sides
32 Write a program to insert 100values and to delete 50 values from an array
dim a(100)
For i = 1 to 100
a(i) = i
If a(i) = 51 Then
Exit
for
Erase
a(i)
End If
print a(i)
Next
33 Write a program to force the declaration of variables
34 Write a program to raise an error and print the error number.
35 Finding whether a variable is an Array
Isarray(a) = true ‘if the variable is really an
array’
Isarray(a) = false ‘if the variable is not an
array’
36 Write a program to Convert value into a
currency
37 Write a program to Convert an expression to a date
38 Display current date and Time
39 Find difference between two dates.
40 Add time interval to a date
41 Print current day of the week
42 Convert Date from Indian Format to US format
43 Find whether current month is a long month
44 Find whether given year is a leap year
45 Format Number to specified decimal places
46 Write a program to Generate a Random Number
47 Write a program to show difference between Fix and Int
48 Write a program to find subtype of a variable
49 Write a program to print the decimal part of a given number
50 Write a Function to return a random number
51 Write a Function to add and multiply two numbers
52 Write a Sub Procedure to print “Hello World”
53 Write a Sub Procedure to add and multiply two numbers
54 Write a program to list the Timezone offset from GMT
37 Write a program to Convert an expression to a date
38 Display current date and Time
39 Find difference between two dates.
40 Add time interval to a date
41 Print current day of the week
42 Convert Date from Indian Format to US format
43 Find whether current month is a long month
44 Find whether given year is a leap year
45 Format Number to specified decimal places
46 Write a program to Generate a Random Number
47 Write a program to show difference between Fix and Int
48 Write a program to find subtype of a variable
49 Write a program to print the decimal part of a given number
50 Write a Function to return a random number
51 Write a Function to add and multiply two numbers
52 Write a Sub Procedure to print “Hello World”
53 Write a Sub Procedure to add and multiply two numbers
54 Write a program to list the Timezone offset from GMT
55 what is the difference between ByVal and
ByVal
Function getval(byval x, byref y)
x =
x+1
y =
y+1
print "x="&x&" "&"y="&y
End Function
Dim a: a = 5
dim b: b
= 5
call getval( a, b )
print "a="&a&" "&"b="&b
No comments:
Post a Comment