PDA

View Full Version : Creating a .exe



sm321
02-03-2012, 08:12 AM
I am looking to make a .exe file which opens in a GUI. But I don't know how to do it. I want it to have functions e.g. type a number in a box. Thanks :)

Sex
02-03-2012, 08:24 AM
I am looking to make a .exe file which opens in a GUI. But I don't know how to do it. I want it to have functions e.g. type a number in a box. Thanks :)

You're going to need to be more specific. Which OS, what language, etc..

ShawnjohnSJ
02-03-2012, 08:42 AM
There are many different programming languages that can create a executable file. There are probably too many for me to list but I'll list the ones that I know of off the top of my head:

C
C++
Delphi
Visual Basic
C#

To get started with GUI's, the easiest would be Visual Basic by Microsoft.
http://www.microsoft.com/visualstudio/en-us/products/2010-editions/visual-basic-express

shadowmarkus
02-03-2012, 08:43 AM
Are you sure you mean an exe? Don't you mean a form in Simba? That's alot simpler doing than making a program itself.

ShawnjohnSJ
02-03-2012, 08:48 AM
Are you sure you mean an exe? Don't you mean a form in Simba? That's alot simpler doing than making a program itself.

Nonsense... in Visual Basic he can make an executable with GUI components without even touching a piece of code.

sm321
02-03-2012, 08:58 AM
Sorry, I should have put that, I've heard visual basic is easy for a beginner? I've got Windows OS.

ShawnjohnSJ
02-03-2012, 09:02 AM
Sorry, I should have put that, I've heard visual basic is easy for a beginner? I've got Windows OS.

Yes its very easy for beginners and its built for the Windows OS. Just download Visual Basic Express and watch this 6 minute video on how to create a simple calculator.

http://www.youtube.com/watch?v=K2vqJxvg6JM

Wizzup?
02-03-2012, 09:05 AM
Yes its very easy for beginners and its built for the Windows OS. Just download Visual Basic Express and watch this 6 minute video on how to create a simple calculator.

http://www.youtube.com/watch?v=K2vqJxvg6JM

It may be easy for beginners, but if you begin with stuff like that you'll most of the time never get much further than a beginner... No offense intended.

sm321
02-03-2012, 09:12 AM
It may be easy for beginners, but if you begin with stuff like that you'll most of the time never get much further than a beginner... No offense intended.

It's ok :) I will hopefully get to grips with this, understand it more then maybe move on. I don't know yet.


Yes its very easy for beginners and its built for the Windows OS. Just download Visual Basic Express and watch this 6 minute video on how to create a simple calculator.

http://www.youtube.com/watch?v=K2vqJxvg6JM

I have Windows XP 2003, is that a problem?

ShawnjohnSJ
02-03-2012, 09:13 AM
It may be easy for beginners, but if you begin with stuff like that you'll most of the time never get much further than a beginner... No offense intended.

I can understand why people think that since its a very high level language and you don't have to deal pointers, memory management, etc but its not always true. I started out in Visual Basic around 2004 and I'm pretty good in C++, no where near an expert, but not bad for being self-taught. However I do agree that its not a language you should stick to for long, but it is a good language to get your feet wet into the programming world.


I have Windows XP 2003, is that a problem?
Not at all.

sm321
02-03-2012, 09:18 AM
There are many different programming languages that can create a executable file. There are probably too many for me to list but I'll list the ones that I know of off the top of my head:

C
C++
Delphi
Visual Basic
C#

To get started with GUI's, the easiest would be Visual Basic by Microsoft.
http://www.microsoft.com/visualstudio/en-us/products/2010-editions/visual-basic-express

It says that type of file can harm my computer?

ShawnjohnSJ
02-03-2012, 09:19 AM
It says that type of file can harm my computer?

When you download the executable for Visual Basic Express 2010?

sm321
02-03-2012, 09:20 AM
When you download the executable for Visual Basic Express 2010?

Yes the link you gave me. Also, it says I need 3GB of space left, is that how much it takes up?

ShawnjohnSJ
02-03-2012, 09:21 AM
Yes the link you gave me. Also, it says I need 3GB of space left, is that how much it takes up?

That's just telling you that .exe files are potentially dangerous. That file is from Microsoft's website so you don't have anything to worry about. Yes it takes up 3GB of space.

sm321
02-03-2012, 09:22 AM
That's just telling you that .exe files are potentially dangerous.

That's ok then :)


That file is from Microsoft's website so you don't have anything to worry about. Yes it takes up 3GB of space.

Could it be saved to an external hard drive?

ShawnjohnSJ
02-03-2012, 09:25 AM
That's ok then :)



Could it be saved to an external hard drive?

Yes I suppose it could.

sm321
02-03-2012, 09:28 AM
I'm on it now, and I've made a simple calculator using this tutorial http://www.youtube.com/watch?v=K2vqJxvg6JM, yet it doesn't work. This next bit may be confusing but here goes. If I type say 5 in text box 1, click the + button, type 6 in text box 2, the answer says 5 not 11. Why is it doing that?

ShawnjohnSJ
02-03-2012, 05:32 PM
I can't help you without seeing your code. Use the CODE brackets and post your code.

sm321
02-03-2012, 05:34 PM
I can't help you without seeing your code. If possible, use the
brackets and post your code.

I think I know how to fix it. I think it needs an equals button.

ShawnjohnSJ
02-03-2012, 05:35 PM
I think I know how to fix it. I think it needs an equals button.

Yeah that makes sense. :p

sm321
02-03-2012, 05:37 PM
Yeah that makes sense. :p

Public Class Form1

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Label2.Text = "-"
Label1.Text = Val(TextBox1.Text) - Val(TextBox2.Text)
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Label2.Text = "+"
Label1.Text = Val(TextBox1.Text) + Val(TextBox2.Text)
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Label2.Text = "x"
Label1.Text = Val(TextBox1.Text) * Val(TextBox2.Text)
End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Label2.Text = "/"
Label1.Text = Val(TextBox1.Text) / Val(TextBox2.Text)

That's my code, I have to press 5+6+ to make it work

ShawnjohnSJ
02-03-2012, 05:41 PM
Are you putting in 5 and 6 before you press the + button? That looks like the only way you can do it with the way its coded.

sm321
02-03-2012, 05:43 PM
Are you putting in 5 and 6 before you press the + button? That looks like the only way you can do it with the way its coded.

It worked properly if I put the two numbers in then click +. I'm only practising anyway :)

ShawnjohnSJ
02-03-2012, 05:45 PM
It worked properly if I put the two numbers in then click +. I'm only practising anyway :)

Yes the way its coded thats the only way to do it.. however you can code it a different way once you get better. (You can look for more tutorials on youtube or Google for creating a better calculator).

Edit: Here, this is a little more complex than the last tutorial but it'll give you some good knowledge.
http://www.youtube.com/watch?v=J-e7aqDktRQ

sm321
02-03-2012, 05:47 PM
Yes the way its coded thats the only way to do it.. however you can code it a different way once you get better. (You can look for more tutorials on youtube or Google for creating a better calculator).

I've made an equals button which has made the calculator work, but I've only made work for +. How do I make it work for all 4 +-*/

ShawnjohnSJ
02-03-2012, 05:49 PM
I've made an equals button which has made the calculator work, but I've only made work for +. How do I make it work for all 4 +-*/

That depends on how you coded the function for the equals button. Let me see the code.

sm321
02-03-2012, 05:51 PM
That depends on how you coded the function for the equals button. Let me see the code.

Label2.Text = "+"
Label1.Text = Val(TextBox1.Text) + Val(TextBox2.Text)

I just copied and pasted the + button's coding :)

ShawnjohnSJ
02-03-2012, 05:54 PM
Label2.Text = "+"
Label1.Text = Val(TextBox1.Text) + Val(TextBox2.Text)

I just copied and pasted the + button's coding :)

You won't be able to do it that way. I can't give you example code because I haven't programmed in Visual Basic in years, but if you look at the YouTube video I posted 2 posts ago, it'll show you how to correctly do it.

ShawnjohnSJ
02-03-2012, 06:03 PM
I've made an equals button which has made the calculator work, but I've only made work for +. How do I make it work for all 4 +-*/

Well you would have to recode some of your program to make it work for an equals button.. the only reason it works for addition is because you're basically performing the addition twice.

Give me a few minutes and I'll try to write up some code that'll have an equals button.

Edit: Try this code.. I don't know if it works because I don't have visual basic installed but it should work. It will only work for 2 numbers. Make sure your equals button is named "Button5"


Dim firstValue as Double

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
firstValue = Val(TextBox1.Text)
Label2.Text = "-"
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
firstValue = Val(TextBox1.Text)
Label2.Text = "+"
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
firstValue = Val(TextBox1.Text)
Label2.Text = "x"
End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
firstValue = Val(TextBox1.Text)
Label2.Text = "/"
End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Label2.Text = "="
Label1.Text = firstValue / Val(TextBox2.Text)
End Sub

sm321
02-03-2012, 07:35 PM
Well you would have to recode some of your program to make it work for an equals button.. the only reason it works for addition is because you're basically performing the addition twice.

Give me a few minutes and I'll try to write up some code that'll have an equals button.

Edit: Try this code.. I don't know if it works because I don't have visual basic installed but it should work. It will only work for 2 numbers. Make sure your equals button is named "Button5"


Dim firstValue as Double

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
firstValue = Val(TextBox1.Text)
Label2.Text = "-"
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
firstValue = Val(TextBox1.Text)
Label2.Text = "+"
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
firstValue = Val(TextBox1.Text)
Label2.Text = "x"
End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
firstValue = Val(TextBox1.Text)
Label2.Text = "/"
End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Label2.Text = "="
Label1.Text = firstValue / Val(TextBox2.Text)
End Sub

Thanks, I'll try that sometime :) But I've encountered another problem, I've got this code:
Val(TextBox2.Text) = Val(TextBox5.Text) - Val(TextBox4.Text) * Val(TextBox6.Text)

Yet it says 'Expression is a value and therefore cannot be the target of an assignment'.

ShawnjohnSJ
02-03-2012, 07:43 PM
Thanks, I'll try that sometime :) But I've encountered another problem, I've got this code:
Val(TextBox2.Text) = Val(TextBox5.Text) - Val(TextBox4.Text) * Val(TextBox6.Text)

Yet it says 'Expression is a value and therefore cannot be the target of an assignment'.

TextBox2.Text is a variable. When you do Val(TextBox2.Text) it converts that string into an integer (hence Val=Value).. what you're doing here is setting the integer value of TextBox2.Text to ... which doesn't make any sense.

To put that into simpler terms, only use Val after the equals sign.


TextBox2.Text = Val(TextBox5.Text) - Val(TextBox4.Text) * Val(TextBox6.Text)

sm321
02-03-2012, 07:49 PM
TextBox2.Text is a variable. When you do Val(TextBox2.Text) it converts that string into an integer (hence Val=Value).. what you're doing here is setting the integer value of TextBox2.Text to ... which doesn't make any sense.

To put that into simpler terms, only use Val after the equals sign.


TextBox2.Text = Val(TextBox5.Text) - Val(TextBox4.Text) * Val(TextBox6.Text)

It hasn't come up with an error, yet text box 2 is still blank :wacko:

ShawnjohnSJ
02-03-2012, 07:51 PM
It hasn't come up with an error, yet text box 2 is still blank :wacko:

Send me your code via PM and I'll help you.

Rezozo
02-03-2012, 08:09 PM
I agree with Wizzup?, he is a B O S S btw.
If you want to learn any programming, start with basic or pascal!

n3ss3s
02-03-2012, 08:47 PM
It may be easy for beginners, but if you begin with stuff like that you'll most of the time never get much further than a beginner... No offense intended.

Yes, and considering actual VB coding rather than messing with the form designer, it's syntax and ideas are very, very different from the "leading" languages (which future languages are based on).

ShawnjohnSJ
02-03-2012, 10:12 PM
Yes, and considering actual VB coding rather than messing with the form designer, it's syntax and ideas are very, very different from the "leading" languages (which future languages are based on).

True, the syntax is very different and the idea of event-driven programming gets you into a completely different mindset than if you were programming in C++, Java, etc. What I meant by it being a good language for starters is not having to mess around with creating the code for GUI's (which can be daunting sometimes) and easy manipulation of components on the GUI. Its very easy for someone to jump right in and create a calculator (for example) and learn about variables, expressions, methods, etc. But everyone has different opinions and preferences, I guess its just a matter of where you feel comfortable starting off at.

Daniel
02-04-2012, 10:02 AM
It may be easy for beginners, but if you begin with stuff like that you'll most of the time never get much further than a beginner... No offense intended.

BASIC was really just designed to teach the use of types, control structures, and the like, in a nice easy manner. I agree that it is good for learning, but disagree to constantly use it for everything.

sm321
02-04-2012, 10:27 AM
I've had a little practice with it and want to make a Runescape Calculator of some sort, but what should I make?

Daniel
02-04-2012, 01:08 PM
I've had a little practice with it and want to make a Runescape Calculator of some sort, but what should I make?

RuneScape calculator?

Richard
02-04-2012, 01:32 PM
BASIC was really just designed to teach the use of types, control structures, and the like, in a nice easy manner. I agree that it is good for learning, but disagree to constantly use it for everything.

To be fair, Pascal was designed as a language for learning, and it's by the far the most used language on this forum. Even Java is used largely as a method of teaching people the ways of OOP, although it is used in some large applications today.

sm321
02-04-2012, 03:19 PM
RuneScape calculator?

One that calculates something for Runescape e.g. type in your xp and it tells you time to get a level or something Runescape related.