Tuesday, October 22, 2019

The Useful Generic List in VB.NET

The Useful Generic List in VB.NET Generics extend the power and flexibility of VB.NET in a lot of areas, but you get a bigger performance benefit and more programming options in the generic List object [List(Of T)] than with any other. To use List(Of T), you have to understand how to implement the many methods that the .NET Framework provides. Below are three examples using ForEach, FindAll, and Sort, that demonstrates how the generic List class works. The very first step is to create a generic List. You can get the data in a lot of ways, but the simplest is to just Add it. The code below shows how to classify my beer and wine collection! Starting Code There first needs to be an object that will represent a bottle from the collection. In a Windows Forms application, the Form class has to first be in a file or the Visual Studio designer wont work correctly, so put this at the end: Public Class Bottle Public Brand As String Public Name As String Public Category As String Public Size As Decimal Public Sub New( _ ByVal m_Brand As String, _ ByVal m_Name As String, _ ByVal m_Category As String, _ ByVal m_Size As Decimal) Brand m_Brand Name m_Name Category m_Category Size m_Size End Sub End Class To build the collection, Add the items. This is whats in the Form Load event: Dim Cabinet As List(Of Bottle) _ New List(Of Bottle) Cabinet.Add(New Bottle( _ Castle Creek, _ Uintah Blanc, _ Wine, 750)) Cabinet.Add(New Bottle( _ Zion Canyon Brewing Company, _ Springdale Amber Ale, _ Beer, 355)) Cabinet.Add(New Bottle( _ Spanish Valley Vineyards, _ Syrah, _ Wine, 750)) Cabinet.Add(New Bottle( _ Wasatch Beers, _ Polygamy Porter, _ Beer, 355)) Cabinet.Add(New Bottle( _ Squatters Beer, _ Provo Girl Pilsner, _ Beer, 355)) All of the above code is standard code in VB.NET 1.0. However, note that by defining your own Bottle object, you get the benefits of multiple types in the same collection (in this case, both String and Decimal) and efficient, type safe late binding. ForEach Example The fun starts when we use the methods. To begin, lets implement the familiar ForEach method. The Microsoft documentation includes this usage syntax definition: Dim instance As List Dim action As Action(Of T) instance.ForEach(action) Microsoft further defines action as delegate to a method that performs an action on the object passed to it. The elements of the current List(T) are individually passed to the Action(T) delegate. Tip: For more on delegates, read Using Delegates in Visual Basic .NET for Runtime Flexibility. The first thing you need to code is the method that will be delegated. Misunderstanding this one key point is the source of most of the confusion of VB.NET students. This function, or subroutine, is where all of the customized coding for the Of type objects is done. When performed correctly, youre essentially done. Its really simple in this first example. An entire instance of the Bottle is passed and the subroutine selects anything needed out of it. Coding the ForEach itself is simple too. Just fill in the address of the delegate using the AddressOf method. Sub displayBottle(ByVal b As Bottle) ResultList.Items.Add( _ b.Brand ) ResultList.Items.Add(-) Cabinet.ForEach(AddressOf displayBottle) End Sub FindAll Example FindAll is a little more complicated. The Microsoft documentation for FindAll looks like this: Dim instance As List Dim match As Predicate(Of T) Dim returnValue As List(Of T) returnValue instance.FindAll(match) This syntax includes a new element, Predicate(Of T). According to Microsoft, this will represent the method that defines a set of criteria and determines whether the specified object meets those criteria. In other words, you can create any code that will find something in the list. I coded my Predicate(Of T) to find anything in the Beer Category. Instead of calling the delegate code for each item in the list, FindAll returns an entire List(T) containing only the matches that result from your Predicate(Of T). Its up to your code to both define this second List(T) and do something with it. My code just adds the items to a ListBox. Private Sub FindAllButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FindAllButton.Click ResultList.Items.Clear() ResultList.Items.Add(FindAll Example) ResultList.Items.Add(-) Dim sublist As List(Of Bottle) sublist Cabinet.FindAll(AddressOf findBeer) For Each r As Bottle In sublist ResultList.Items.Add( _ r.Brand - _ r.Name - _ r.Category - _ r.Size) Next End Sub Function findBeer(ByVal b As Bottle) _ As Boolean If (b.Category Beer) Then Return True Else Return False End If End Function Sort Example The final method this article examines is Sort. Again, Microsoft uses some terminology you might not be familiar with. There are actually four different overloads of the Sort method: Sort()Sort(IComparer(T))Sort(Comparison(T))Sort(Int32, Int32, IComparer(T)) This lets you use sort methods defined in the .NET Framework for the list, code your own, use a system defined comparison for the type, or sort part of the collection using a starting position and count parameter. In this example, since I use the following syntax to actually perform the sort, Im using the third overload. x.Name.x.Name.CompareTo(y.Name)(y.Name) Ive coded another delegate to my own comparer. Since I want to sort by my Name, I pull just that value out of each instance of the Bottle object that is passed and use the Sort(Comparison(Of (T))). The Sort method actually rearranges the original List(T). Thats what is processed after the method is executed. Private Sub SortButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SortButton.Click ResultList.Items.Clear() ResultList.Items.Add(Sort Example) ResultList.Items.Add(-) Cabinet.Sort(AddressOf sortCabinet) For Each r As Bottle In Cabinet ResultList.Items.Add( _ r.Name - _ r.Brand - _ r.Category - _ r.Size) Next End Sub Private Shared Function sortCabinet( _ ByVal x As Bottle, ByVal y As Bottle) As Integer Return x.Name.CompareTo(y.Name) End Function These methods were selected to demonstrate the major ways that the Framework methods in List(T) are actually coded. Theres a whole raft of other methods, however. Thats what makes List(T) so useful!

Monday, October 21, 2019

How Oprah Winfrey Overcame Failure

How Oprah Winfrey Overcame Failure Imagine being born in rural 1950s Mississippi to an impoverished teenage mother. Imagine suffering abuse from the age of 9, then running away from home at 13, only to become pregnant at 14 and lose your first child. Now imagine you’re Oprah. Sound implausible? It’s actually true. Oprah was able to turn the tables on this disastrous upbringing, but it took guts and grit. She moved to Tennessee to live with her father, and began to excel in school. She did well in speech and debate. She even won a state beauty pageant. All while working part-time reading news for a local radio station until she could earn a scholarship to college at Tennessee State.In college, this wounded girl became a powerhouse of a woman. She majored in communications, and landed her first post-graduation job at a Nashville station. That turned into a bigger gig with an ABC affiliate in Baltimore. Soon after that, she was hired as a primetime news co-anchor, an incredible feat considering she was a yo ung, black woman in an era where old, white men made and enforced all the rules.There was a publicity campaign before her debut. The network wanted to broaden their viewership. Suddenly, Oprah Winfrey was thrust into the spotlight with high expectations. She was set up for failure. When the show failed, she was blamed- and not her old, white, male co-host. She was demoted to a writing and reporting gig, but was a slow writer and too caring for the kind of hard-nosed reporting required. (On one notable occasion, she was so moved by the plight of a family who had lost their things in a fire, that she donated some of her blankets and supplies to them, drawing flack from her boss.)Even Oprah herself looks back on these years as a failure. But she did not give up. Instead, she took stock of the situation, realized that, while she loved television, she preferred human interest stories to hard news. And while she loved hosting, she had to have significant chemistry with a co-host to make t hat relationship worthwhile.Eventually, all of this soul-searching paid off. She took a job co-hosting a show called People are Talking with Richard Sher. To anyone else, this would have been considered a step down. But Oprah made lemonade. The show was successful enough to run for five years, after which Oprah was recruited to host a morning talk show in Chicago. That show became a household name. And Oprah became an international sensation.What Oprah had was a unique combination of empathy, determination, and the ability to keep moving forward when all else had fallen apart. Her ability to excel in business while not being business-oriented is a marvel. Moral of the story? Have passion, believe in your dreams, believe in yourself even when no one else does, and keep going when hope is lost. Don’t be afraid to fail.Oprah Winfrey: A Profile in Failure

Sunday, October 20, 2019

Reading Motivation - Activities for Elementary Students

Reading Motivation - Activities for Elementary Students Teachers are always looking for ways to boost their students reading motivation. Research confirms that a childs motivation is the key factor in successful reading. You may have noticed students in your classroom who are struggling readers, tend to have a lack of motivation and do not like to partake in book-related activities. These students may have trouble selecting appropriate texts, and therefore do not like to read for pleasure. To help motivate these struggling readers, focus on strategies that will help spark their interest and boost their self-esteem. Here are five ideas and activities to increase your students reading motivation and encourage them to get into books. Book Bingo Motivate students to read a variety of books by playing Book Bingo. Give each student a blank bingo board and have them fill in the squares with some of the suggested phrases: I read a mystery bookI read a funny bookI read a biographyI read an animal storyI read a book about friendship Students can also fill in the blanks with I read a book by..., or I read a book about... Once they have their bingo board labeled, explain to them that in order to cross off a square, they must have met the reading challenge that was written(Have students write the title and author of each book they read on the back of the board). Once the student gets bingo, reward them with a classroom privilege or a new book. Read and Review A great way to make a reluctant reader feel special, and motivate them to want to read, is by asking them to review a new book for the class library. Have the student write a brief description of the plot, main characters, and what he/she thought of the book. Then have the student share his/her review with their classmates. Thematic Book Bags A fun way for younger students to boost their reading motivation is to create a thematic book bag. Each week, select five students to be chosen to take home a book bag and complete the assignment thats in the bag. Inside each bag, place a book with theme-related contents in it. For example, place a Curious George book, a stuffed monkey, a follow-up activity about monkeys, and a journal for the student to review the book in the bag. Once the student returns the book bag have them share their review and activity that they completed at home. Lunch Bunch A great way to pique your students interest in reading is to create a reading lunch bunch group. Each week select up to five students to participate in a special reading group. This entire group must read the same book, and on a determined day, the group will meet for lunch to discuss the book and share what they thought about it. Character Questions Encourage the most reluctant readers to read by having them answer character questions. In the reading center, post a variety of character pictures from the stories your students are currently reading. Under each photo, write Who am I? and leave space for children to fill in their answers. Once the student identifies the character, they must share more information about them. Another way to do this activity is to replace the photograph of the character with subtle hints. For example His best friend is a man in a yellow hat. (Curious George). Additional Ideas Enlist parents to come in and be a mystery reader.Participate in the Pizza Hut Book-It program.Have a Read-a-Thon.Pair students together with a book buddy.Play Name That Book where students have to guess the title of the book you just read to them.

Saturday, October 19, 2019

Topics to be Investigated Research Paper Example | Topics and Well Written Essays - 250 words

Topics to be Investigated - Research Paper Example An Evaluation of the Extent to Which Social, Economic, and Environmental Factors Influence the Process of Waste Disposal Waste disposal is a process that involves myriad activities and also brings on board different stakeholders that play different roles. Social, economic, and environmental factors are the likely critical aspects that influence waste disposal and management. While the activities, stakeholders, and influential factors are known, the extent to which these factors influence the process of waste disposal is fundamental to assess, evaluate and subsequently discover. The operational relationship between the activities, stakeholders, and influential factors in the process are uncertain or unknown, making necessary to discover this relationship. Research problem: Social, economic, and environmental factors influence waste disposal processes, but the magnitude and extent of this influence need to be researched. Paradigm Shifts in the Use of Alternative Green Energy Sources in Combating Climate Change Climate change has persistently become a global issue, with the trends in global warming and climate change, in general, showing an over the years increase. This has raised the need for the alternative use of green energy sources in order to try and reverse the contemporary trends in climate change. The paradigm shift from the use of pollutant energy sources to the use of green energy sources in combating climate change is a critical aspect of discovering. This follows the fact that the substitution of alternative sources of energy is personally uncertain.

Friday, October 18, 2019

Different Types of Data in Criminal Justice Assignment

Different Types of Data in Criminal Justice - Assignment Example 2. The age issue could lead to confusing findings in substance abuse research. This is because most countries have laws that prescribe the legal drinking age. For instance the legal drinking age in United States is 21 while in United Kingdom it is 18 (Bamforth, 2009). As a result, youths who are below the drinking age may give wrong age for fear that legal action may be taken against them. Therefore, giving such information may be difficult to the respondents. This is a powerful graph used to show the proportion or relative sizes of data. For this survey the percentage of males and females involved in substance abuse could be better presented using pie chart. Each gender would be represented by each segment of the pie chart. A bar graph consists of vertical and horizontal bars whose lengths indicate the magnitude of the data. In this research, the bar graph would be appropriate in representing the amount of substance abused or the popularity of the substance. The frequency or the amount of substance would be placed on the vertical axis while the type of substance would be on the horizontal axis. The trend of change between the drinking age and the years could be well captured in by line graph. This would be done by plotting the average age against the year. By doing so, the relationship between age the year would be

Essay Example | Topics and Well Written Essays - 3500 words

Essay Example The seven wastes include motion; transportation; waiting time; overproduction; inventory; processing time; and defects. Other common wastes are energy; untapped human resources; and by-products. Motion and transport are related to layout; organisation; and engineering. Waste arises as motion and transport does not always result in useful work. In the current case study, motion and transportation includes rearrangement of storage areas that are temporary before and after manufacture or product components; and movement associated with searching fixtures, jigs, tools, equipment, materials, etc. Movement allows an opportunity for product damage during handling and movement; poor space utilisation – large distances between stages or large gangways or storage areas; higher labour cost from low productivity; large batches waiting for transport – large inventories, long leadtimes, low responsiveness. Waiting time, overproduction and inventory are related to scheduling; setups; communication; quality; skills; reward systems; breakdowns; and layout. Waiting time could be caused by material; machine; or labour. Lack of material could be caused by scrap; breakdown; poor schedule; or poor supplier. Machine unavailability could be caused by breakdown; setups; large batches; or unavailability of tools, jigs, fixtures, etc. Skills shortage, absenteeism, or operating or supervising more than one machine could cause skill shortage. Overproduction could be a case of too much or too early. Too much is when there is more production than needed. This could be caused by setups that are long, improper scheduling for EOQ, or inadequate design of processes. Too early includes production earlier than required. This could be caused by lack of machine capability, subcontracting of operations, long in-process delays, or long leadtimes. Overproduction could also be caused by unbalanced material flow; cushion storage; safety storage; and lot delays.

Thursday, October 17, 2019

Ratio analysis Essay Example | Topics and Well Written Essays - 2500 words

Ratio analysis - Essay Example The former is used to compare the performance of the firm within itself in terms of aspects such as improvement in management skills and finance handling. The latter is used to compare the performance of the firm within its industry of operation. Such comparisons will consider fundamental aspects of operations like profitability. In profitability, an increase or decrease is established and the causes of each including what can be done to stabilize profitability and grow it further. The liquidity of the firm is also quite fundamental as this would enable management know how to plan operations and sources of financing. Therefore, ratio analysis is used in the determination of trends as it strives to expose the strengths and weaknesses of the company. Ratios can be either favorable or unfavorable depending on whether the increase or decrease is in the desired direction (Dess 2012). For our analysis of Apple Incorporation’s financial statement of the year 2012 compared to that of the year 2011, we will categorize ratios into the following - Profitability Ratios; Liquidity ratios; Efficiency Ratios and Capital structure ratios. Profitability Ratios They measure the ability of the company to generate profits from their asset investments. Such ratios include- Gross Profit margin, which is the profit before expenses generated by sales as a percentage. There is the Net Profit margin which are the earnings before depreciation and tax generated by sales; Then there is the Return on Equity(ROE)/Net Worth/ Shareholders funds/ Investments(ROI), this is the ratio of the earnings after tax plus preference dividends contributed by share capital and reserves. The fourth ration in this category is the Return on total assets (ROTA) which indicates how much the Fixed and Current Assets of a company contributes to the Earnings before Interest and Tax (EBIT). Return on Capital Employed is the next, it indicates how equity and Fixed interest capital contributes to the EBIT, and finally we have the Operating Expenses Ratio indicating the percentage of sales consumed by the operating expenses. An increase in these ratios from the previous period is considered favorable while a decrease in the last ratio is considered favorable. The ratios as shown by the financial data by Apple incorporation between the years 2011 and 2012 financial statements are as shown in the table below. RATIO FORMULA YEAR 2012($ in Millions) YEAR 2011($ in Millions) 1. Gross Profit Margin = (Gross Profit/Sales)*100 (66,662/156,508)*100 = 43.87% (43,818/108,249)*100 = 40.48% 2. Net Profit Margin =(EBIT/Sales)*100 (55,241/156,508)*100 = 35.30% (34,790/108,249)*100 = 32.14% 3. ROE/ROI =(EAT+ Pref. dividends/Owner’s Equity)*100 (41,733/118,210)*100 = 35.30% (25,922/76,615)*100 = 33.83% 4. ROTA =(EBIT/Total Assets)*100 (55,241/176,064)*100 = 31.38% (34,790/116,371)*100 = 29.90% 5. ROCE =(EBIT/Total Capital Employed)*100 (55,241/118,210)*100 = 46.73% (34,790/76,615)*100 = 45.41% 6. O perating Expenses Ratio =(Operating Expenses/Sales)*100 (13,421/156,508)*100 = 80.58% (10,028/108,249)*100 = 9.26% As indicated by the profitability ratios, there was a general increase in profitability of Apple Inc between the year 2011 and 2012. The gross profit margin shows a rise from 40.48% in 2011 to 43.87% in 2012. Such an increase was because of the increase in; sales from 108,249 in 2011 to 156,508 in 2012. An increase of the net profit margin from 32.14% to 35.3% is because of the i