The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 2 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
a simple way to use real time data to populate a form.
If you go to real clear politics
http://www.realclearpolitics.com/epolls/latest_polls/president/
You will see that there’s all the latest polls with a spread in the right hand column. Create a program wherein the user types in a candidate (we’ll assume the user
types in the candidates name correctly), and the program outputs the latest spread for
that particular candidate. For example the September 23rd Spread for the Democratic
Presidential Nomination is Clinton +8. So if a user types in Clinton, it will output 8.
And that’s it! First thing, How do we get this number from the webpage? If you right click
on the webpage you can “View the source” of the page. You’ll see HTML code. Search
for “Clinton +” (i.e. Find Clinton + on the webpage). You will see that it finds the first
Clinton + and the number right after it is the spread we want (Spreads are always nonnegative
because someone is in the lead)! In fact the number is in between Clinton +
and <.
"">Clinton +8</span>
uneditable text box
editable text box,
i.e. user writes
Clinton, or Trump
button that if user
clicks the bottom
text box gets
populated with 8.
In visual basic you can get the whole webpage html as a string using the following
command:
!Dim!sourceString!As!String!=!New!System.Net.WebClient().DownloadString("http://
www.realclearpolitics.com/epolls/latest_polls/president/")
In visual basic you can split a string by using the Split command.
if I had a string panther=“Panther Pride Week” and I Split on the spaces like so
Dim!fun!As!String()!=!Split(panther,!"!")
After this command fun will be a string array with “Panther” as its first element “Pride” as
its second element and “Week” as its third element. For example if we MsgBox(fun(0))
we’d see “Panther”.
So back to our Visual Basic. The user puts in a candidates name in the text box. We
look at the textbox’s text to figure out who the candidate is. Then we can use Split a few
times to find the number between “<candidates name, i.e. Clinton or Trump or Sanders>
+” and the “<“.
Split once and then split again...
Finally we write this out to the text box and Bam-- we have our first Real Time Visual
Basic Application!
This GUI is very bare bones. The functionality is basic. To get full points you should do
one of the side quests (extra credit for the harder ones):
Side Quests:
1) The GUI isn’t the best. Make the GUI more presentable and add another function
(like a dropdown menu that preloads the candidate names, labels for all the text
boxes, or maybe a Toolbar with buttons of 3 or 4 candidates faces on it that I can
select)
2) The information of the candidate spread is devoid of Date or the the Race/Topic
column information. Read these off the website and Incorporate one or both of these
pieces into the GUI (extra credit)
3) Allow the User to also Pick one Topic, From a Dropdown menu (i.e. Iowa or
Democratic Presidential Nomination or Republican Presidential Nomination), in
addition to a candidate and only give the Spread of that contest (extra credit)
4) Anything else that you might find interesting (Toolbar with candidates pictures I can
select instead of typing? Right Click that does something? Tooltips on all the
elements? Main menu?). Be as creative as you want, but make a clear argument that
your addition improved the deliverable in some way-- If you go this route you might
want to include a ReadMe.