Add a line to the top of a text file
daniva ForReading and ForWriting – that we’ll use when working with our text file.
daniva ForReading and ForWriting – that we’ll use when working with our text file.
daniva Reading the last line of a file is a workaround. There is no script that reads just the last line of a text file. But here’s a script that will make it look like you read just the last line of a text file:
daniva GUID (global unique identifier) is a term used by Microsoft for a number that its programming generates to create a unique identity for an entity such as a Word document. GUIDs are widely used in Microsoft products to identify interfaces, replica sets, records, and other objects. Different kinds of objects have different kinds of GUIDs - for instance, a Microsoft Access database uses a 16-byte field to establish a unique identifier for replication.
daniva Sometimes we need to generate a random string to use in our tests. The following code generates a random string of alpha characters. You can extend the function to generate additional strings.
daniva Adds quotes to a filename… especially useful when sending an argument to a program (ie a filename) and it has spaces in it (with spaces if shows up as multiple arguments.
daniva The following function formats messages, using the Dot.Net format principle.
daniva Use the LCase function and to convert a string to lower-case.
Use the UCase function and to convert a string to upper-case.
daniva Use the LTrim, RTrim, and Trim to trim whitespace from a string.
daniva The string operator & performs a string concatenation also the + operator.
daniva Use the Space and String to create a string having a single character repeated N times.
daniva Use the StrComp function and vbTextCompare argument to compare strings without case sensitivity.
daniva Use the Right Function to extract a substring from the end of a string.
daniva Use the Mid Function to modify a substring within a string
daniva Use the Len Function to return the length of a string.
daniva Use the Left Function to extract a substring from the beginning of a string.
daniva Use IsDate to determine if a string contains a valid date.
daniva Find the starting position of the last occurrence of a substring within a string. ( With strings, the first character is at position 1 )
daniva VBScript has no built-in function where we can find all occurrences of a substring inside a string. Only regular with expressions ( Regexp ) the task is easier. However you need to use Regexp, Matches, and Match objects.
daniva Use the CItn function to Determine if a string contains a substring.
daniva Use the CStr to convert a number into it’s string representation
daniva The Asc function takes an ASCII character code and returns the character.
daniva The Asc function returns the ASCII code of the first character in the string.
daniva VBScript has a built-in function called DatePart that can take any date you give it and tell you everything from the hour to the minute to the day of the week. All you have to do is pass DatePart two items:
The content you are accessing is for registered users onlyRegisteration is FREE, quick and private.You […]
daniva what if you want to retrieve today’s date? But what about yesterday’s date? it’s just as easy to determine yesterday’s date as it is today’s date. That’s because VBScript can do date arithmetic: give it today’s date, and then you can simply subtract 1 day to determine yesterday’s date. In other words:
Yaron Assa Possible ByRef catastrophes
The example from part 1 (regarding passing objects as ByVal parameters) might lead us to believe that when passing an object to a function, we shouldn’t care less if it’s passed ByVal or ByRef, as we’re passing the object’s reference in any case. Any change to the object within the function’s scope will […]
Yaron Assa A very refreshing debate at SQAForums has really opened my eyes on the small details involved with Objects, Scopes and Procedure calls. I thought it was a good idea to write a summary of what went on there, and I took the opportunity and added a very detailed background about many basic terms that may […]
Yaron Assa Yesterday I was in for a very pleasant surprise - I’ve just installed Visual Studio 2008, and was working on a QTP test, when I’ve noticed a something strange with QTP’s Debug view.
Usually when you add a watch to an Object, QTP will present it as an enigmatic “<Object>”, with no further description. If you’re […]
Yaron Assa We are already proud to present the very first addition to the First Steps section - a unique VBScript tutorial.
The tutorial is composed of 18 presentations (11 basic + 7 advanced), which ease you into the world of VBScript usage, and allow you to understand the simple concepts of programming before moving into the actual code examples and more advanced subjects.
Recent Comments