Google
 

Thursday, December 28, 2006

Try ,Try and Try again

Today was a rather uneventful day. So as usual i was lazing about at home chatting with friends. After being a rather uneasy third wheel in converstaion involving 2 of my friends. I suddenly relaised how incomplete the phrase

"Try , Try and try again"
I mean not taking away from the important message it conveys and all, but when you think about it practically it leaves out another important idea which shuld be related to it The idea of Trying a different approach each time. To often in life we come up against a barrier , obstacle , bump on the road or simply put a situtation which really throws a monkey wrench in to the machinatiom of your daily life. It is your actions in this situation that sets you apart from the rest of the pack.
It takes courage , valour and a strong heart and mind to face these situation and to win.Now you may not win all the time but its importanat you keep trying to win . Nut most importantly one must not stick with one plan and try to batter your way through the problem because you may see little success or worse that approach may cost you dearly in the long run. So trying varied approaches to the problem is key because it allows you a greater chance of success plus more importantly it Allows you to gain more understanding of yourself and of your strengths and limitations.

ANOTHER point to remember is one must never be pig headed and one must be able to handle defeat as a hero would with your head held high and one must be openminded to the opportunity to sidestep these obstacles when its is clear thatsurmounting them might be to costly.

Intelligence , courage, strength and Honor are virtues which should be cultivated in the new gneration.

Wednesday, December 27, 2006

overview of Ruby Part 1

First of all Ruby is an interesting language basically its coding is composed of simple english sentences which can be understood by both computers and people. The thing to remember the syntax relies on using puncuation marks at the proper point. THIS IS IMPORTANT. On to the basics of ruby

Variable- in ruby any plain or lower caseword is a variable, it may consist of letter, digits or underscore.
eg rouge, 1242 or attack_foils
these are used to refer to things within your coding

Numbers- there are 2 types of number

        • Integers - for basic digits
            • in these you cannot use commas between digits
eg: 12 or 1000_000_000
        • Floats - this what decimal numbers are called in ruby any number with scientific annotaion can also be called a floa
eg 3.14, -808.08
String - Strings are any sought off collectin of characters whicj are surrounded by quotes
both double and sigke quotes are used to denote strings
eg : "I am the Darth Mara" & ' I wish '

Symbols - These are words thta look like varibles but start with a colon (:)
eg- :Anderson , :X1
They can be considered as lightweight strings which wont be written to the screen

Constants-
Any Capitalized word is a constant in Ruby. They are used to insert unchanging information in coding
eg: Time , Array

Methods - Methods are usually attached to the end of a variable by a dot
eg : attack_foils.lock
if variables were the nouns of ruby then methods would be the verbs of it . so basically methods are action that can be omplemented on the variable.



To be continued

Tuesday, December 26, 2006

ONE CLICK INSTALLER FOR RUBY ... for beginners

hey i found this link for a one click insatller for ruby on the windows XP platform . heres the link
http://rubyforge.org/projects/rubyinstaller/
this is a godsend for people jus looking 2 experiment with Ruby

Sunday, December 10, 2006

Ruby

One of my brothers friends told me 2 chek out this programming language called ruby last week and i did.. and let me tell you i'm hooked on it. Its been around for awhile and its one off the few totally object oriented languages out there.. And the best part its completely free becuase its being developed under an open source liscence.. I'm including somesites any1 interested in finding out more should visit them ..

Well for the next few weeks i hope 2 learn more about ruby and i'll share it wit u all as i go along

Linking 2 forms in VB.Net and using textbox input from the first in the second

well it took me awhile to find out hw to do this properly but anyway its pretty simple to do this
Lets us take 2 forms Form1 & Form2 And we will call Form2 From Form1.. The coding for Form1 will involve declaring the textbox we will use as Shared Textbox..

Form1 Coding
Dim f2 As New Form2
Public Shared newname As TextBox

Private Sub cmdgoto_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdgoto.Click
'makes txtuser textbox the public shared textbox newname
newname = txtuser

f2.Show()
Me.Hide()



End Sub


End Class


The line in red is the most important because it allows you 2 use the textbox commonly between the 2 forms

*after u add this to the first form u need not add any more coding 2 da second to initialise the above function mentioned in the heading .. ohh but wen u wnt 2 exit the program u must specify in the second form tht both form1 and form2 shuld be closed.


Lucky 7 Game Coding using Vb.net

As part of my first year ICT practitioner Module I had to build this Lucky 7 gAME using vb.net.. it ws fun and engaging so i decided to share the coding with everyone(this is better thn saying i wanted to show off Grin ... HEY HOLD on i just said tht . Well nvrmind )

Public Class Form2
Inherits System.Windows.Forms.Form
'declaration of variables used by the program
Dim guess1 As Integer
Dim guess2 As Integer
Dim guess3 As Integer
Dim wincount As Integer
Dim spincount As Integer

Private Sub clearvalues()
'initialises the values of the count values and generates 3 random numbers
wincount = 0
spincount = 0
Randomize()
Randomize()
guess1 = (Int(Rnd() * 9) + 0)
guess2 = (Int(Rnd() * 9) + 0)
guess3 = (Int(Rnd() * 9) + 0)

End Sub
Private Sub rndvalues()
'calls randomizer function and generates 3 random values
Randomize()
guess1 = (Int(Rnd() * 9) + 0)
guess2 = (Int(Rnd() * 9) + 0)
guess3 = (Int(Rnd() * 9) + 0)

End Sub
Private Sub showvalues()
'displays the random numbers in respective label
lblguess1.Text = guess1
lblguess2.Text = guess2
lblguess3.Text = guess3



End Sub
Private Sub wincounter()
'checks each random number for the value 7 and displays the approriate message
If guess1 = guess2 = guess3 = 7 Then
Call incrementwincountby3()

lblmsg.Text = Form1.newname.Text & " " & "You have hit the JACKPOT"
System.Console.Beep()

Else
If guess1 = guess2 = 7 Then
Call incrementwincountby2()

lblmsg.Text = Form1.newname.Text & " " & "You have a Double win"
System.Console.Beep()


Else
If guess1 = guess3 = 7 Then
Call incrementwincountby2()

lblmsg.Text = Form1.newname.Text & " " & "You have a Double win"
System.Console.Beep()

Else
If guess3 = guess2 = 7 Then
Call incrementwincountby2()

lblmsg.Text = Form1.newname.Text & " " & "You have a Double win"
System.Console.Beep()
Else
If guess1 = 7 Then
incrementwincountby1()

lblmsg.Text = Form1.newname.Text & " " & "You are a winner"
System.Console.Beep()

Else
If guess2 = 7 Then
incrementwincountby1()

lblmsg.Text = Form1.newname.Text & " " & "You are a winner"
System.Console.Beep()


Else
If guess3 = 7 Then
incrementwincountby1()

lblmsg.Text = Form1.newname.Text & " " & "You are a winner"
System.Console.Beep()

Else

lblmsg.Text = Form1.newname.Text & " " & "Try Again"
End If
End If
End If
End If
End If
End If
End If

End Sub
Private Sub incrementwincountby1()
'adds 1 to the wincount
wincount = wincount + 1
lblwincount.Text = wincount


End Sub
Private Sub incrementwincountby2()
'adds 2 to the wincount
wincount = wincount + 2
lblwincount.Text = wincount

End Sub
Private Sub incrementwincountby3()
'adds 3 to the wincount
wincount = wincount + 3
lblwincount.Text = wincount

End Sub

Private Sub spincounter()
'adds 1to the spincount
spincount = spincount + 1
lblspincount.Text = spincount


End Sub
Private Sub cmdspin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdspin.Click
'gets all the functions to run on the clicking spin button
Call rndvalues()
Call showvalues()
Call wincounter()
Call spincounter()


End Sub
Private Sub cmdexit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdexit.Click
Me.Close()
Form1.Close()

End Sub
Private Sub cmdrestart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdrestart.Click
' calls required functions to restart application
Call clearvalues()
Call showvalues()



End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'calls procedures to initializes the values of the application
Call clearvalues()
Call showvalues()
lblwincount.Text = wincount
lblspincount.Text = spincount
lblmsg.Text = "Try your hand"

End Sub


End Class