Fusion Universe
April 18, 2024, 06:16:48 pm
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Forum Launched
 
  Home Help Search Arcade Gallery Staff List Login Register  

Hello World Tutorial

Pages: [1]
  Print  
Author Topic: Hello World Tutorial  (Read 44 times)
Sunreal
Admin Crew
Ultime User
********
Offline Offline

Posts: 1001


I like elfenlied :D


View Profile WWW
« on: July 29, 2008, 07:35:47 am »

I see loads of hello world tutorials, but they are only saying such small things, so i will post an hello world tutorial, bit more advanced then others.

lets start!! Grin Grin

have a new project + 1 form ready:

after that, create 2 objects.
1 command button : with text: I am here!
1 label , with no text ( or on form load, label1.caption = "" )

have it somewhat like this:

now, here comes the code:
double click on the command button
then write the following code:
(btw, everything with an ' before it, is a comment)

dim hw as byte
hw = Rnd(1) ' this basicly sets the byte hw to either 1 or 0 ( like an boolean )
'rnd(number) means that the program will generate numbers between 0 and the value you enter in number

'now we do a value check
if hw = 0 then label1.caption = "Hello there!!" else label1.caption = "yo!"

'basicly, you now are asking a question: if hw = 0 "the question", then do, caption = "hello there!!",
'if that question has not the answer we are looking for, then its value is false, and you can use an else action:
'caption = "yo"

ok, this is our code

dim hw as byte
hw = Rnd(1)
if hw = 0 then label1.caption = "Hello there!!" else label1.caption = "yo!"


ok, press F5 or the blue arrow, and TEST if it works!
the result will be, that if you press the button multiple times, it will display another text.

now, i want that in the second message, it also gives the current time and date, there are multiple ways to get it, but i do the following:

instead of
else label1.caption = "yo!"
replace it with
else label1.caption = "man, today its " & Now()
'now() is a time format, it gets the current date and time
this will display : man, today its "current time"

after you press multiple times now, you will see, "Hello there!!!", and "man, today its 'current date'"

that was my hello world tutorial


sunreal, fusion universe
FuT, Fusion universe Tutorials
« Last Edit: August 08, 2008, 12:38:26 pm by Sunreal » Report Spam   Logged

Share on Facebook Share on Twitter

Pages: [1]
  Print  
 
Jump to:  

Bookmark this site! | Upgrade This Forum
Free SMF Hosting - Create your own Forum

Powered by SMF | SMF © 2016, Simple Machines
Privacy Policy