Free Games Forum
Free Games Games Forums Music Forums TV Forums

  Free Games Forum Home FORUM
HOME
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN
Rules & FAQ RULES / FAQ
REPORT SPAM

Free Games Forum: Game Technology: Visual Basic / VB:
TUT Useful Codelets (vb.net)

 

 


Jaymzanator
Enthusiast


Jun 21, 2006, 3:23 AM

Post #1 of 1 (485 views)
Shortcut
TUT Useful Codelets (vb.net) Can't Post

1. Caps lock: Basic: * - Jaymzanator.com


Quote

The My.Computer.Keyboard object can be used to determine the current state of the keyboard, including such things as whether NUM LOCK or CAPS LOCK is on.
To determine if CAPS LOCK is on
To determine whether or not CAPS LOCK is on, use the My.Computer.Keyboard.CapsLock property. The following code displays a message about the state of the CAPS LOCK.

Code
  If My.Computer.Keyboard.CapsLock Then   
MsgBox("CAPS LOCK is on")
Else
MsgBox("CAPS LOCK is off")
End If



2. Get Data from teh clipboard - Basic: ** - Jaymzanator.com


Quote

The Clipboard can be used to store data, such as text and images. Because the Clipboard is shared by all active processes, it can be used to transfer data between them. The My.Computer.Clipboard object allows you to easily access the Clipboard and to read and write to it. The GetText, GetImage, GetData, GetAudioStream, and GetFileDropDownList methods allow you to specify what type of data you would like to read from the Clipboard.
If data cannot be retrieved from the Clipboard, an ExternalException is thrown.
To read text from the Clipboard and display it
Use the My.Computer.Clipboard.GetText method to read the text. The following code reads the text and displays it in a message box. There must be text stored on the Clipboard for the example to run correctly.

Code
  MsgBox(My.Computer.Clipboard.GetText())


This code example is also available as an IntelliSense code snippet. In the code snippet picker, it is located in Windows Forms Applications > Clipboard. For more information, see How to: Insert Snippets Into Your Code (Visual Basic).
To read an image from the Clipboard
Use the My.Computer.Clipboard.GetImage method to read an image from the Clipboard. The following code reads an image from the Clipboard and assigns it to the Image property of Button1. There must be an image stored on the Clipboard and a Button named Button1 for the example to run correctly.

Code
   
Button1.Image = My.Computer.Clipboard.GetImage()



3. Write to clipboard - Basic: ** - Jaymzanator.com


Quote

The Clipboard can be used to store data, such as text and images. Because the Clipboard is shared by all processes, it can be used to transfer data between them. The My.Computer.Clipboard object allows you to easily access the Clipboard and to read and write to it. The SetAudio, SetData, SetFileDropDownList, SetImage, and SetText methods allow you to place data on the Clipboard.Security Note
Because the Clipboard can be accessed by other users, do not use it to store sensitive information, such as passwords or confidential data.
To write text to the Clipboard
Use the My.Computer.Clipboard.SetText method to write text to the Clipboard. The following code writes the string "This is a test string" to the Clipboard.

Code
 My.Computer.Clipboard.SetText("This is a test string.")

To write text to the Clipboard in a specific format
Use the My.Computer.Clipboard.SetText method to write text to the Clipboard, including the type of TextDataFormat. The following code writes the string "This is a test string" to the Clipboard as RTF text.

Code
 My.Computer.Clipboard.SetText("This is a test string.", _  
System.Windows.Forms.TextDataFormat.Rtf)

To write data to the Clipboard
Use the My.Computer.Clipboard.SetData method to write data to the Clipboard. This example writes the DataObject dataChunk to the Clipboard in the custom format specialFormat.
Visual Basic
My.Computer.Clipboard.SetData("specialFormat", dataChunk)


4. Play System Sounds - Basic: ** - Jaymzanator.com

Quote

This example uses the My.Computer.Audio.PlaySystemSound method to play a system sound.
The My.Computer.Audio.PlaySystemSound method takes as a parameter one of the shared members from the SystemSound class.
Example
Use the My.Computer.Audio.PlaySystemSound method to play the specified system sound.
The system sound Asterisk generally denotes errors. For more information, see SystemSound.

Code
Sub PlaySystemSound()  
My.Computer.Audio.PlaySystemSound( _
System.Media.SystemSounds.Asterisk)
End Sub



5. Upload Files to a server - Basic: *** - Jaymzanator.com

Quote
The My.Computer.Network.UploadFile Method can be used to upload a file and store it to a remote location. If the ShowUI parameter is set to True, a dialog box is displayed that shows the progress of the download and allows users to cancel the operation.
To upload a file Use the UploadFile method to upload a file, specifying the source file's location and the target directory location as a string or URI (Uniform Resource Identifier).This example uploads the file Order.txt to http://www.jaymzanator.com/uploads.aspx.

Code
My.Computer.Network.UploadFile( _ 
"C:\My Documents\Order.txt", _
"http://jaymzanator.com/upload.aspx")

To upload a file and show the progress of the operation Use the UploadFile method to upload a file, specifying the source file's location and the target directory location as a string or URI. This example uploads the file Order.txt to http://jaymzanator.com/uploads.aspx without supplying a user name or password, shows the progress of the upload, and has a time-out interval of 500 milliseconds.

Code
My.Computer.Network.UploadFile( _ 
"C:\My Documents\Order.txt", _
"http://jaymzanator.comupload.aspx", "", "", True, 500)

To upload a file, supplying a user name and password Use the UploadFile method to upload a file, specifying the source file's location and the target directory location as a string or URI, and specifying the user name and the password. This example uploads the file Order.txt to http://jaymzanator.com/uploads.aspx, supplying the user name anonymous and a blank password.

Code
My.Computer.Network.UploadFile( _ 
"C:\My Documents\Order.txt", _
"http://jaymzanator.com/upload.aspx", "anonymous", "")



6. Download files from a server - Basic: *** - Jaymzanator.com

Quote

The My.Computer.Network.DownloadFile Method can be used to download a remote file and store it to a specific location. If the ShowUI parameter is set to True, a dialog box is displayed showing the progress of the download and allowing users to cancel the operation. By default, existing files having the same name are not overwritten; if you want to overwrite existing files, set the overwrite parameter to True.
The following conditions may cause an exception:
Drive name is not valid (ArgumentException).
Necessary authentication has not been supplied (UnauthorizedAccessException or SecurityException).
The server does not respond within the specified connectionTimeout (TimeoutException).
The request is denied by the Web site (WebException).Note
The options available in dialog boxes, and the names and locations of menu commands you see, might differ from what is described in Help, depending on your active settings or edition. This Help page was written with General Development Settings in mind. To change your settings, choose Import and Export Settings on the Tools menu. For more information, see Visual Studio Settings.
Security Note
Do not make decisions about the contents of the file based on the name of the file. For example, the file Form1.vb may not be a Visual Basic source file. Verify all inputs before using the data in your application. The contents of the file may not be what is expected, and methods to read from the file may fail.
To download a file
Use the DownloadFile method to download the file, specifying the target file's location as a string or URI and specifying the location at which to store the file. This example downloads the file WineList.txt from http://jaymzanator.com/downloads and saves it to C:\Documents and Settings\All Users\Documents:

Code
My.Computer.Network.DownloadFile _ 
("http://jaymzanator.com/downloads/WineList.txt", _
"C:\Documents and Settings\All Users\Documents\WineList.txt")

To download a file, specifying a time-out interval
Use the DownloadFile method to download the file, specifying the target file's location as a string or URI, specifying the location at which to store the file, and specifying the time-out interval in milliseconds (the default is 1000). This example downloads the file WineList.txt from http://jaymzanator.com/downloads and saves it to C:\Documents and Settings\All Users\Documents, specifying a time-out interval of 500 milliseconds:

Code
My.Computer.Network.DownloadFile _ 
("http://jaymzanator.com/downloads/WineList.txt", _
"C:\Documents and Settings\All Users\Documents\WineList.txt", False, 500)

To download a file, supplying a user name and password
Use the DownLoadFile method to download the file, specifying the target file's location as a string or URI and specifying the location at which to store the file, the user name, and the password. This example downloads the file WineList.txt from http://www.cohowinery.com/downloads and saves it to C:\Documents and Settings\All Users\Documents, with the user name anonymous and a blank password.

Code
My.Computer.Network.DownloadFile _ 
("http://jaymzanator.com/downloads/WineList.txt", _
"C:\Documents and Settings\All Users\Documents\WineList.txt", "anonymous", "")Security Note


The FTP protocol used by the DownLoadFile method sends information, including passwords, in plain text and should not be used for transmitting sensitive information.



more coming soon ...


(17:20) Taz:
and tazg is lol'in at you all the way from canada
(17:21) James:
lol canadians


 
 
 


Search for (options) Web Design by Web Ideas - Page loaded in: 0.11 s on (CGI/1.1)