<< 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

what is want, cost,
Muhammad Reply
in what ways is monopolist competition different from perfect competition
Juliana Reply
what is economics
Lizzy Reply
is the study of how you can make your own business to develop yourself and even the other countries
the study of economic enable us to practice how to manage and arranged our daily basic of life.
Economics is a science that studies human behaviour as a relationship between ends and scarce means. .
Am I totally agree the scare means are the wants and beings the humans need
simple meaning.....Demand and Supply
economics is science and art economics means , branch of that knowledge which teach of economic nature
Expalin why demand curve for a perfectly competitive firm is perfectly elastic and eams normal profit in the long run
Abdi Reply
how does elasticity helps in our daily lives
Chris Reply
it help me a lot, in search for slipper I can purchase shoe, in such for car I can purchase bike it helps a lot to everyone in the world.
List and explain four factors of production
Vuyo Reply
capital labour entrepreneur natural resources
land labour entrepreneur capital
What is supply
Ogodo Reply
when the supply decreases demand also decreases
supply is the quantity of good and services a producer is willing to supply to the market for sale at a particular price
when supply decrease daman is high
supply is the quantity of goods and services which willing to supply to market to sale a particular price
types of demand and the explanation
akin Reply
what is demand
akin Reply
other things remaining same if demend is increases supply is also decrease and if demend is decrease supply is also increases is called the demand
if the demand increase supply also increases
you are wrong this is the law of demand and not the definition
Demand is the willingness of buy and ability to buy in a specific time period in specific place. Mian you are saying law of demand but not in proper way. you have to keep studying more. because its very basic things in Economics.
Demand is the price of Quantity goods and services in which consumer's are willing and able to offer at a price in the market over a period of time
Demand is the quantity of goods and services that the consumer are willing and able to buy at a alternative prices over a given period of time. But mind you demand is quite different from need and want.
Demand can be defined as the graphical representation between price&demand
sorry demand is nt a graphical representation between price and quantity demand but instead that is demand curve.
Demand is the willingness and ability of a consumer to buy a quantity of a good over a given period of time assuming all other things remain constant.
Demand is define as the good's and services,that a consumer is willing and able to purchase at a particular period of time.
what is commercialization?
Doris Reply
commercial is the process of changing non profit orientating organisation to profit orientating organisation.
How to talk loan for bank?
Alfred Reply
what is the meaning of gpa?
Ritisha Reply
Answer: GPA stands for Grade Point Average. It is a standard way of measuring academic achievement in the U.S. Basically, it goes as follows: Each course is given a certain number of "units" or "credits", depending on the content of the course.
what is small and Microbuisenes
tadesse Reply
What is fiscal policy
Who is the funder of Economic
founder , that is Adam Smith
Adams smith
what is model
Daniel Reply
The wealth of Nations
Yusuf Reply
the wealth of nations, is it the first?
Yes very sure it was released in 1759
thank you Yusuf.
then when did he died?
17 July 1790 Born: 16 June 1723, Kirkcaldy, United Kingdom Place of death: Panmure House, Edinburgh, United Kingdom
that's my today questions, thank you Yusuf it's bed time see u after.
Difference between extinct and extici spicies
Amanpreet Reply
While the American heart association suggests that meditation might be used in conjunction with more traditional treatments as a way to manage hypertension
Beverly Reply
in a comparison of the stages of meiosis to the stage of mitosis, which stages are unique to meiosis and which stages have the same event in botg meiosis and mitosis
Leah Reply
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?