New Rich Text Document

Please download to get full document.

View again

of 2
6 views
All materials on our website are shared by users. If you have any questions about copyright issues, please report us to resolve them. We are always happy to assist you.

Download

Document Related
Document Description
When I first started to learn how to program Windows applications I was mystified by the Windows Registry. I discovered that programs would store information there and most normal users would never even know about it. This was the perfect place to store encrypted passwords and things like that. Of course now days the registry is becoming less and less helpful because it has grown enormously and is a pain to move when a computer is upgraded. Still storing a value in the registry, especially pro
Document Share
Document Tags
Document Transcript
  When I first started to learn how to program Windows applications I was mystified bythe Windows Registry. I discovered that programs would store information there andmost normal users would never even know about it. This was the perfect place tostore encrypted passwords and things like that. Of course now days the registry isbecoming less and less helpful because it has grown enormously and is a pain to movewhen a computer is upgraded. Still storing a value in the registry, especially programsettings or things such as that, can be very helpful. This code snippet shows you howto use Visual Basic's built in SaveSetting and GetSetting commands to store andretrieve data in the registry. To use this code create a new Visual Basic project, add two command buttons to it, addtwo text boxes. Go to the code area and add the following source code.Private Sub Command1_Click()SaveSetting MyString , New , Test , Text1.TextEnd Sub Private Sub Command2_Click()Text2.Text = GetSetting( MyString , New , _  Test , vbNullString)End Sub Private Sub Form_Load()Text1.Text = This is a Test Command1.Caption = Write Value Command2.Caption = Read Value End SubAfter you have added the source, run your program and you should be able to saveand retrieve data from the registry. ________________________________________________________________________________________  _______________  You can always close your current form with the Unload Visual Basic command. Whenthat line is encountered your form will disappear. However, wouldn't it be moreexciting if instead of just disappearing your form collapsed in towards the center of itself and then disappeared. The way we do this is by setting the forms width andheight to a smaller amount over and over again. This can be done easily with a Dowhile loop. The important thing is to make sure you stop collapsing the form before itgets too small. You will get an error if you set the width or height to anything less than0. To try this out create a Visual Basic 6 project and a command button to your mainform. Double click on the command and enter the following code in the click eventhandler for your button.Do While Me.Width > 1800Me.Width = Me.Width - 300Me.Left = Me.Left + 150If Me.Height - 400 ThenMe.Top = Me.Top - 1Me.Height = Me.Height - 150End If Loop  Unload Form1: EndOnce you have the code entered run your program and click the button. You shouldsee your form leave with a little style ________________________________________________________________________________________  _______________ An often requested task that new developers to VB ask is how can I write a programthat will launch other programs. Its fun to create your own little launcher program thatdoes things like allows you to quickly launch just the programs you want. Obviouslyprogram launchers already exist out on the market that you could simply use. But oneof the great things about learning a programming language like Visual Basic is that youcan create your own programs that behave exactly how you want them to. To try out the this sample source code snippet simply create a VB project, add acommand button to the main form, double click this button to get into the click eventhandler for it and add the following code.Dim ResDim FilenameFilename = C:\windows\notepad.exe 'Check file is here firstIf Dir(Filename) = ThenMsgBox Filename & not found , vbInformationElseRes = Shell( Start.exe & Filename, vbHide)End If  This source code uses the VB6 Shell command to launch a new program. Wespecifically call the Start.exe program as it can be used to launch other programseasily.
Search Related
We Need Your Support
Thank you for visiting our website and your interest in our free products and services. We are nonprofit website to share and download documents. To the running of this website, we need your help to support us.

Thanks to everyone for your continued support.

No, Thanks