Fusion Universe |
March 29, 2024, 07:12:52 am | ||||
|
News: Forum Launched |
Home | Help | Search | Arcade | Gallery | Staff List | Login | Register |
11
on: August 13, 2008, 02:28:19 pm
|
||
Started by Lucy - Last post by Lucy | ||
i like my 1000 posts who doesnt
|
12
on: August 08, 2008, 12:37:33 pm
|
||
Started by Sunreal - Last post by Sunreal | ||
hey, there are loads of ways to code a calculator, but i do it this way, so i dont want to have a talk so lets begin
have an form with the following buttons and text box: (btw, i forgot to add the "+" button on this image, sorry! I dont care how you call your calculator and what you enter as start value in the textbox well, double-click on the button with number 1 on it. now, write the following code: (btw, i assume you take '0,' as starting value) If Text1.Text = "0," Then Text1.Text = "1" Else Text1.Text = Text1.Text + "1" explination of the code: if ( start for asking a question ) text1.text = "0," (the question itself) then (if value question is true, then it will do the following expression) text1.text = "1" ( the If True expression ) else (if question asked is false, it performs the following expression) text1.text = text1.text + "1" or in other words, this code makes the text "1" if the textbox is "0," do the same with all other 8 buttons with the numbers, but replace the number "1" with the value of the button with the zero button, add this code: If Not Text1.Text = "0," Then Text1.Text = Text1.Text + "0" now we set-up our values, so lets make it do stuff but for this, we need a module make a module, and add the following code Global reminder1 As String Global reminder2 As String global changer as string global answer as string you can also do a private reminder, but i am at this moment to lazy what the simple codes for that are. now, lets code the rest now, lets make the devide buttons first ( the slash "/" ) changer = "/" If Not Val(Text1.Text) = "0" Then reminder1 = Val(Text1.Text) Else MsgBox "Incorrect divide value!!", vbInformation, "Error" If Val(Text1.Text) = "0" Then changer = "" Text1.Text = "0" now, lets make the "=" button work for the slash "/" If changer = "/" Then GoTo divide Exit Sub divide: If Val(Text1.Text) = "0" Then MsgBox "Incorrect divide value!!", vbInformation, "Error" If Not Val(Text1.Text) = "0" Then reminder2 = Val(Text1.Text) answer = reminder1 / reminder2 Text1.Text = answer reminder1 = Text1.Text End If End Sub now try it i wont explain the code, because its better to find out yourself how this code works now, with that, i want that when i press clear, my screen is 'clear' so simple, add this code to that button reminder1 = "" reminder2 = "" changer = "" text1.text = "0" now, with that, lets start coding the * (multiply ) button by editing its buttons code changer = "*" reminder1 = Val(Text1.Text) Text1.Text = "0" now, again, lets edit the = button so we have the following code: If changer = "/" Then GoTo divide If changer = "*" Then GoTo multiply Exit Sub divide: If Val(Text1.Text) = "0" Then MsgBox "Incorrect divide value!!", vbInformation, "Error" If Not Val(Text1.Text) = "0" Then reminder2 = Val(Text1.Text) answer = reminder1 / reminder2 Text1.Text = answer reminder1 = Text1.Text End If Exit Sub multiply: reminder2 = Val(Text1.Text) answer = reminder1 * reminder2 Text1.Text = answer reminder1 = Text1.Text end sub now try it, they both work (btw, if you would code a little more, you can have an exact copy of the options as windows calculator, but we arent doing that so) now, the both work, lets continue with the - and + buttons the - button and + button: "-" changer = "-" reminder1 = Val(Text1.Text) Text1.Text = "0" "+" changer = "+" reminder1 = Val(Text1.Text) Text1.Text = "0" and once again, lets edit the = button till you got the following code: If changer = "/" Then GoTo divide If changer = "*" Then GoTo multiply If changer = "-" Then GoTo min If changer = "+" Then GoTo plus Exit Sub divide: If Val(Text1.Text) = "0" Then MsgBox "Incorrect divide value!!", vbInformation, "Error" If Not Val(Text1.Text) = "0" Then reminder2 = Val(Text1.Text) answer = reminder1 / reminder2 Text1.Text = answer reminder1 = Text1.Text End If Exit Sub multiply: reminder2 = Val(Text1.Text) answer = reminder1 * reminder2 Text1.Text = answer reminder1 = Text1.Text Exit Sub min: reminder2 = Val(Text1.Text) answer = reminder1 - reminder2 Text1.Text = answer reminder1 = Text1.Text Exit Sub plus: reminder2 = Val(Text1.Text) answer = Val(reminder1) + Val(reminder2) Text1.Text = answer reminder1 = Text1.Text End Sub now try your calculator, after testing the calculator now should work ( i made this tutorial along with the calculator , so everything is tested by me ) you now got a basic calculator, and you can find out the rest yourself, at least, i guess xD |
13
on: August 08, 2008, 08:03:01 am
|
||
Started by Sunreal - Last post by Sunreal | ||
yo, all new guys, be a part of our community, and join open projects, create tutorials, and be a man ( or woman )
sorry, i dont know if i should post this, because its actualy spam |
14
on: August 08, 2008, 04:27:22 am
|
||
Started by cenarius - Last post by Sunreal | ||
, with our new advanced html website, there must be no bugs xD,
it doesnt matter that you arent a programmer or something, thats why this forum excists, this forum is for all people who wish to learn professional things, like photoshop, c++,visual basic, 3d modeling maybe ^^ |
15
on: August 07, 2008, 11:34:49 am
|
||
Started by cenarius - Last post by cenarius | ||
I am not a programmer or something, marco just asked me to check the site for appearance and bugs.
take care |
16
on: July 30, 2008, 04:59:42 am
|
||
Started by Sunreal - Last post by Sunreal | ||
Yo, welcome to my coding tutorial for visual basic 6.0
in this tutorial i will learn you how to loop on serveral ways lets start with simple coding functions well, for almost every code, you use an variable, so lets start with that dim str as string ok, i wrote this, what does it mean? dim = dimension, dunno why its called dimension, but thats not crucial to know. This word gives the accessibility for the variable. ( how larger the value, how more space it will take in the memory ) str = the variables name, you can change it to everything you want it to be, as long as there are no spaces as string = defines it as a string, there are loads of those variable types in visual basic, like listed below: Double long integer byte currency boolean string variant Object so, what are all those variable types? double = can hold from -1.79769313486232E+308 to 1.79769313486232E+308 long = can hold values from -2,147,483,648 to 2,147,483,647 ( and for advanced users: its 32-bit ) integer = can hold values from -32768 to 32767 ( 16-bit ) byte = can hold values from 0 to 255 ( 8-bit ) currency = can hold values from 922,337,203,685,477.5808 to 922,337,203,685,477.5807 ( Dollars ), it changes depending your currency settings. boolean = has only 2 values, TRUE and FALSE, in binairy, it would be 1 and 0 , these words are reserved and cannot be used for itemnames etc. string = a string can hold 0 to 65,400 characters, including symbols and numbers. variant = can hold any data of every type, is mostly used for handling unknown variable types and values Object = A special datatype that holds and references objects such as controls and forms so, now we know that, we can start doing things and lets start with giving of values. (DO NOT FORGET TO ADD A LABEL AND THE FOLLOWING CODE TO A COMMAND BUTTON) Dim str As String Dim B250 As Byte Dim CU As Currency Dim yesno As Boolean Dim lung As Long Dim cheese As Double Dim intt As Integer Dim var As Variant 'now, lets give them a value, by using a integer generator code, named random str = Rnd(10) B250 = Rnd(10) CU = Rnd(10) yesno = Rnd(1) ' it cant handle a higher value then this lung = Rnd(10) cheese = Rnd(10) intt = Rnd(10) var = Rnd(10) Label1.Caption = str & vbNewLine & B250 & vbNewLine & CU & vbNewLine & yesno & vbNewLine & lung & vbNewLine & var & vbNewLine & cheese & vbNewLine & intt & var now, look at the values, and notice, that variable types "byte" and "long" are rounded to a complete value. the rest do all contain a non-rounded value. so, with that, lets start basic functions lung = 5 simple code, lung is the defined variable (long), = makes it equal to 5 ( the value ) lung = rnd(5) + 2 lung is again, the defined variable, but rnd(5), generates an random value, + ( means, it will add the next value ) 2, the last integer value. now, we know how that works, so lets loop it 'our variable integer name is intt for intt = 0 to 5 next intt 'for means, for that variable, ( this case intt ), the starting number is zero, and it will loop till it reaches 5. 'next intt means, it adds + 1 to intt, which is the first loop, 0 lets make a loop, that loops till it reaches our byte variable b250 b250 = rnd(20) for intt = 0 to b250 next intt 'basicly, it now loops, till it reaches the value of b250, which is a random value. now, lets add commands to it, which is in this case, it generates 5 diffrent values in label1 for our double variable named cheese 'label1.caption = "" 'clearing the label first, from any text for intt = 0 to 5 cheese = rnd(100) label1.caption = label1.caption & cheese & vbnewline next intt 'this basicly does 10 actions, 5X rnd(100), and 5X changing label caption 'label1 = our label, cheese is our variable, & vbnewline makes new text starting on a new line this way, you can create a value generator, which generates multiple values. another way to loop (not recommend), is to custom loop intt = 0 startloop: cheese = rnd(100) label1.caption = label1.caption & cheese & vbnewline intt = intt + 1 if not intt = 5 then goto startloop 'startloop is our new label defined, see it as a reference point. same following actions for the looping 'intt = intt + 1 basicly adds everything when the value isn't equal to 5 'if not intt = 5 then goto startloop , if not ( asks a question, if the following expression is true or false ) 'intt = 5 ( the expression) , then goto startloop ( the action, goto startloop, makes the program going to startloop label we defined) so, if i don't recommend, why should i use the the second way? well, it runs much slower then the first way, and maybe needs more memory to work, but an advantage of it is that you can customize this loop, by referring to another point, when a value is smaller, equal, or larger then you want. here is a sample Private Sub Command1_Click() dim secondway as byte for intt = 0 to 100 startloop: secondway = rnd(100) if secondway > 100 then goto exit:' > means bigger then if intt < 100 then goto startloop ' < means smaller then if intt = 100 then label1.caption = "no" exit sub ' this does the same as end sub, but you can use it this way, or you can use it as errorhandler exit: label1.caption = "yes" end sub now, we let the program choose yes or no, depending if variable secondway becomes 100 greetz, sunreal fusion universe FuT, Fusion universe Tutorials |
17
on: July 30, 2008, 04:19:54 am
|
||
Started by Sunreal - Last post by Sunreal | ||
you can see much more of the forum when you register.
still stick to the rules: you can register here http://fusion.freesmfhosting.com/index.php?action=join |
18
on: July 30, 2008, 04:05:39 am
|
||
Started by BarryMCRolld - Last post by BarryMCRolld | ||
Just ask me if you need some
I have tons of Samples and some acapellas but i know a site with tons of acapellas |
19
on: July 30, 2008, 03:57:57 am
|
||
Started by BarryMCRolld - Last post by Sunreal | ||
its funny, but its not made by you ,
if it was made by you, or at least uploaded by you, you where allowed to post it. plz, upload yourself, and change the link |
20
on: July 30, 2008, 03:54:48 am
|
||
Started by BarryMCRolld - Last post by BarryMCRolld | ||