UBound Function VB.NET

Class
Microsoft.VisualBasic.Information

Syntax
UBound(array[, rank])

array

Use: Required

Data Type: Any

The name of the array

rank

Use: Optional

Data Type: Integer

A number specifying the dimension of the array

Return Value
Integer

Description
Indicates the upper limit of a specified coordinate of an array. The upper boundary is the largest subscript you can use with that coordinate.

Rules at a Glance

  • To determine the upper limit of the first coordinate of an array, set rank to 1, set it to 2 for the second coordinate, and so on.
  • If rank is not specified, 1 is assumed.

Programming Tips and Gotchas

  • Note that UBound returns the actual subscript of the upper bound of a particular array dimension.
  • The number of valid indices for the ith coordinate is equal to UBound(array, i) + 1.
  • If array is an uninitialized array, passing it to the UBound function generates an Argument Null Exception exception. To prevent this, you can declare the array as follows:Dim arrValues(-1) As String

UCase Function

Class
Microsoft.VisualBasic.Strings

Syntax
UCase(value)

value

Use: Required

Data Type: String

A valid string expression

Return Value
String

Description
Converts a string to uppercase

Rules at a Glance

  • UCase only affects lowercase alphabetical letters; all other characters within value remain unaffected.
  • UCase returns Nothing if value is Nothing.

Unlock Procedure

Class
Microsoft.VisualBasic.FileSystem

Syntax
Unlock(filenumber[, record)
Unlock(filenumber[, fromrecord[, torecord]])

Filenumber

Use: Required

Data Type: Integer

Any valid file number

record

Use: Required

Data Type: Long

The record or byte number at which to commence the lock

fromrecord

Use: Required

Data Type: Long

The first record or byte number to lock

torecord

Use: Required Data

Type: Long

The last record or byte number to lock

Description
Use the Unlock procedure in situations where more than one part of your program may need read and write access to the same data file. The Unlock procedure removes a lock that the Lock procedure placed on a section of the file or the whole file.

Rules at a Glance

  • Use the Unlock procedure only with the filenumber parameter to unlock the whole file.
  • The Unlock procedure unlocks an entire file opened in Input or Output (sequential) mode, regardless of the record, fromrecord, or torecord arguments.
  • Records and bytes in a file are always numbered sequentially from 1 up.
  • To unlock a particular record, specify its record number as record, and only that record will be unlocked.
  • To unlock a range of bytes (in a binary file) or of records (in a random file), indicate the starting position as fromrecord and the ending position as torecord.

Programming Tips and Gotchas

  • You must take care to remove all file locks using the Unlock procedure before either closing a file or ending the application; otherwise, you can leave the file in an unstable state. This means that, where appropriate, your error-handling routines must be made aware of any locks you currently have in place so that they may be removed if necessary.
  • You use the Lock and Unlock procedures in pairs, and the argument lists of both statements must match exactly.

VB .NET/VB 6 Differences

  • In VB 6, it is possible to omit the fromrecord argument and provide only the torecord argument, in which case all records (in random mode) or bytes (in binary mode) from the beginning of the file to torecord would be unlocked. In VB .NET, this syntax is not allowed.
  • VB 6 allows you to precede the filenumber argument with the # symbol. In VB .NET, this syntax is not permitted.
  • When specifying starting and ending records in VB 6, you use the To keyword to separate them. In VB .NET, this syntax is not permitted; instead, you must use a comma to separate the two arguments.

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

VB.NET Topics