/  3
 
 SEB’s VB.NET Guide
Coding in .Net
The appearance of objects on the form can be changed either at design time or at run-time.
Changing Properties at design time
1.Click on the object2.Click on the property you want to change in the properties window3.Type the new value or select the value from the drop-down menu
 NB: Setting properties at design time is useful for establishing initial values quickly; but setting  properties within code gives the programmer more control over when properties are changed.
Changing Properties at run-time
The structure of a basic statement is:
object.property = value
This changes the property of the specified object to the desired value.
eg:
txtGreeting.text = “Hello”
This sets the text box’s text property to “Hello” – ie: displays “Hello” in the text box.To test the value of a property in a condition, the same structure should be used.
If txtGreeting.text = “Hello” thentxtGreeting.text = “Hi”ElsetxtGreeting.text = “Bye”End if 
This changes the contents of the text box depending on the current contents.
 Page 1 of 3
 
 SEB’s VB.NET Guide
Functions:
Most languages include a library of functions available to reduce duplication of frequently usedcode. These functions usually perform tasks such as searching, sorting or manipulation of strings(extract, delete & insert).
Useful functions:
 STR
Returns a
String
representation of a number 
VAL
Returns the numbers contained in a string as a numeric value of appropriate type
 RND
The function RND can be used to generate a random number. The number generated will be between 0 and 1 so you need to multiply the number by the maximum number youwant to be generated. You need to use the command Randomize to get a different seriesof random numbers each time the code is run.
 Example:
ldblrand 
=
Rnd
*
100
This will generate a random number between 0 and 100 (with decimal places).
 INT 
The function INT takes the integer part of a number. NOTE: It is not the same asrounding! The fractional part of the number is truncated and lost.
 Example:
lintrand 
=
Int
(
Rnd
*
100
)This will generate a
whole
number between 0 and 100.
ABS
Abs takes a number but ignores the sign (+ or -).
 Page 2 of 3

Share & Embed

More from this user

Add a Comment

Characters: ...