Visual Basic Animated Tutorial-Horoscope-SourceCode

Tips:

you can copy paste text below , it is not an image

If you run the code at the bottom of the page in your VB application You need obviously to add on your own elements such as TextBox1,PictureBox1,Button1 in designer.

You need As well to download/import the images renamed as Scorpio.jpg Sagittarius.jpg, Taurus.jpg and so on.


Ternary Operator Explanation:
Ternary operator is something similar to if statement, with the difference that you probably already noticed, takes much less space. Instead of performing a given tasks/ procedure it evaluates("turns itself into something").

Animations - Yay!


Press Button to visualise what "happens" when code runs on the computer

Daisy=25
(Daisy >= 22)

(Daisy is bigger or equal to 22) evaluates to True - because Daisy is 25 so value of 25>=22 is True).Keep in mind that this happens sequentially.

Next Animation shows that ternary operator "turns into" first given value if condition is True


Daisy=25
If((Daisy >= 22), "Capricorn", "Sagittarius")

'if Daisy is bigger or equal to 22 evaluate to "Capricorn" else evaluate to "sagittarius"

Next Animation shows that ternary operator "turns into" second given value if condition is False


Daisy=21
If((Daisy >= 22), "Capricorn", "Sagittarius")

The last animation shows what happens in context of code. Next week i will put something new , probably case statements or how to create your own functions.Stay tuned!


Daisy=21
Sign = If((Daisy >= 22), "Capricorn", "Sagittarius")

'if Daisy is bigger or equal to 22 evaluate to "Capricorn" else evaluate to "sagittarius". Thus our Sign variable has been assigned a value of Sagittarius(in this "False" case).
Later i plan to expand the website with coding examples and tutorials , so keep in touch!


Public Class Form1

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim DOB As Date = New Date
DOB = Convert.ToDateTime(TextBox1.Text)
Dim Sign
Dim Monthy = DOB.Month
Dim Daisy = DOB.Day

Select Case (Monthy)
Case 12 : Sign = If((Daisy >= 22), "Capricorn", "Sagittarius")
Case 11 : Sign = If((Daisy >= 23), "Sagittarius", "Scorpio")
Case 10 : Sign = If((Daisy >= 23), "Scorpio", "Libra")
Case 9 : Sign = If((Daisy >= 23), "Libra", "Virgo")
Case 8 : Sign = If((Daisy >= 23), "Virgo", "Leo")
Case 7 : Sign = If((Daisy >= 23), "Leo", "Cancer")
Case 6 : Sign = If((Daisy >= 22), "Cancer", "Gemini")
Case 5 : Sign = If((Daisy >= 22), "Gemini", "Taurus")
Case 4 : Sign = If((Daisy >= 21), "Taurus", "Aries")
Case 3 : Sign = If((Daisy >= 21), "Aries", "Pisces")
Case 2 : Sign = If((Daisy >= 20), "Pisces", "Aquarius")
Case 1 : Sign = If((Daisy >= 21), "Aquarius", "Capricorn")
'If((condition),"thing returned if condition is True","thing returned if condition is False")'
End Select

MessageBox.Show(Sign)
PictureBox1.ImageLocation = Sign & ".jpg"
'the string can be a full image url(web address http://) as well'
'it means that you need to put all your images into bin/debug directory and name As the signs above
PictureBox1.Load()
End Sub


End Class

thanks to James Padolsey http://james.padolsey.com for his findAndReplaceDOMText which helped with this project

thanks to Ivan Sagalaev for his highlight.js, without it wouldnt make much sense