<< Chapter < Page
  Ti dsp/bios lab   Page 1 / 1
Chapter >> Page >
The module is a lab assignment to help you better understand the very basics of Microsoft Visual Basic delegates.


This lab module will help you become familiar with the basics of delegates in Microsoft Visual Basic(V). The exercises are written assuming you are using Visual Basic 2005 and the .NET Framework version 2.0 (or later). Some older versions will work the same, but you may need to figure out some differences. It should work with newer version also.

Module prerequisites

You should complete the Visual Basic Threads and Semaphores lab before this one.


Part 1

  • In this part you will make a project with a thread that will try to change a TextBox text without using a delegate method. When the thread tries to change the TextBox text it won't work because the TextBox control is not handled by the thread.
  • Start up Visual Studio and create a new Visual Basic project.
  • On the GUI, put a new TextBox. By default it should have the name TextBox1 .
  • Create a thread called Task1 and start the thread in the Form1_Load method.
  • In the thread method Task1 , assign a string to the TextBox.
  • Run your program and observe what happens. You should get an error when the thread tries to access the TextBox control. Record what the error says.

Part 2

  • In this part we will make a delegate that will allow the thread to change the text in the TextBox.
  • Either start a new project or modify the one from the previous part. What you should have in your project is:
  1. A TextBox on the GUI with the name TextBox1 .
  2. A thread called Task1 that is started in the Form1_Load method.
  • Add commands to define a delegate type and an instance of a delegate. If you want to use the names shown here you can. These statements should be right under the beginning of the Form1 class (right after " Public Class Form1 ").
Delegate Sub DelegateType(ByVal myStr As String) Dim IDel As New DelegateType(AddressOf DelegateMethod)
  • Make a new DelegateMethod method that takes a string as an input and uses it to change the text of the TextBox.
  • In the Task1 method, use the TextBox1 to invoke the delegate method. Have it write the text "Task Text" to the TextBox.
  • Run your program and observe that the text "Task Text" gets written to the TextBox.

Part 3

  • In this part we will make a simple clock. All we will do is continuously get the current time and write it to the TextBox.
  • In this part we will have everything that is in the previous part so you can start where it left off. Your project should have:
  1. A TextBox on the GUI with the name TextBox1 .
  2. A thread that uses the Task1 method that is started in the Form1_Load method.
  3. Commands to define a delegate and an instance of a delegate.
  4. A delegate method that writes the input string to the TextBox.
  • In the thread, we will have it get the current date/time and the write it to the TextBox.
  • Put the following commands that will define objects to get the current date/time.
Dim count As Integer Dim dispDt As DateTimeDim datePatt As String = "M/d/yyyy hh:mm:ss tt" Dim dtString As String
  • In the thread make a continuous while loop that puts the date into the string dtString and then sends that string to the delegate. To get the date use the command:
dispDt = DateTime.Now ' get the time now dtString = dispDt.ToString(datePatt) ' Convert the date to a string
  • In the while loop make the thread sleep for 100 ms so that it is not doing too much processing. It will get the time/date and write it to the TextBox every 100 ms.
  • Run your program and observe that the text displays the date/time and that the seconds change.

Questions & Answers

How we are making nano material?
what is a peer
What is meant by 'nano scale'?
What is STMs full form?
scanning tunneling microscope
what is Nano technology ?
Bob Reply
write examples of Nano molecule?
The nanotechnology is as new science, to scale nanometric
nanotechnology is the study, desing, synthesis, manipulation and application of materials and functional systems through control of matter at nanoscale
Is there any normative that regulates the use of silver nanoparticles?
Damian Reply
what king of growth are you checking .?
What fields keep nano created devices from performing or assimulating ? Magnetic fields ? Are do they assimilate ?
Stoney Reply
why we need to study biomolecules, molecular biology in nanotechnology?
Adin Reply
yes I'm doing my masters in nanotechnology, we are being studying all these domains as well..
what school?
biomolecules are e building blocks of every organics and inorganic materials.
anyone know any internet site where one can find nanotechnology papers?
Damian Reply
sciencedirect big data base
Introduction about quantum dots in nanotechnology
Praveena Reply
what does nano mean?
Anassong Reply
nano basically means 10^(-9). nanometer is a unit to measure length.
do you think it's worthwhile in the long term to study the effects and possibilities of nanotechnology on viral treatment?
Damian Reply
absolutely yes
how to know photocatalytic properties of tio2 nanoparticles...what to do now
Akash Reply
it is a goid question and i want to know the answer as well
characteristics of micro business
for teaching engĺish at school how nano technology help us
How can I make nanorobot?
Do somebody tell me a best nano engineering book for beginners?
s. Reply
there is no specific books for beginners but there is book called principle of nanotechnology
how can I make nanorobot?
what is fullerene does it is used to make bukky balls
Devang Reply
are you nano engineer ?
fullerene is a bucky ball aka Carbon 60 molecule. It was name by the architect Fuller. He design the geodesic dome. it resembles a soccer ball.
what is the actual application of fullerenes nowadays?
That is a great question Damian. best way to answer that question is to Google it. there are hundreds of applications for buck minister fullerenes, from medical to aerospace. you can also find plenty of research papers that will give you great detail on the potential applications of fullerenes.
what is the Synthesis, properties,and applications of carbon nano chemistry
Abhijith Reply
Mostly, they use nano carbon for electronics and for materials to be strengthened.
is Bucky paper clear?
carbon nanotubes has various application in fuel cells membrane, current research on cancer drug,and in electronics MEMS and NEMS etc
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get the best Algebra and trigonometry course in your pocket!

Source:  OpenStax, Ti dsp/bios lab. OpenStax CNX. Sep 03, 2013 Download for free at http://cnx.org/content/col11265/1.8
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Ti dsp/bios lab' conversation and receive update notifications?