Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Dec 4th, 2005, 5:39 PM   #11
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
You're declaring your variable inside the function. Every time you call the function, the variable intNumber is created, incremented and destroyed. You can work around this in one of two ways: you can use a global variable, which is created when the application starts and destroyed on exit, and declared outside of any function (usually at the top of Form or Module code), or you can declare the variable as static, which will tell it to retain its value even after the function finishes:
Static intNumber As Integer
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Dec 4th, 2005, 10:53 PM   #12
Psychosis
Newbie
 
Join Date: Nov 2005
Posts: 5
Rep Power: 0 Psychosis is on a distinguished road
So like:

Dim intNumber As Integer

Private Sub btnClick_Click()
intNumber = intNumber + 1

lblCount.Caption = "Count: " & intNumber

End Sub

Edit:

YES!! It works!!

Well it's the end of the night for me, I'll be back soon!! Thanks!!
Psychosis is offline   Reply With Quote
Old Dec 5th, 2005, 2:21 AM   #13
Ghost
Man Bear Pig Hunter
 
Ghost's Avatar
 
Join Date: Jul 2005
Location: NorCal, USA
Posts: 295
Rep Power: 4 Ghost is on a distinguished road
12 Post for something that counts when you press a button....only in VB
Ghost is offline   Reply With Quote
Old Dec 5th, 2005, 8:39 PM   #14
Psychosis
Newbie
 
Join Date: Nov 2005
Posts: 5
Rep Power: 0 Psychosis is on a distinguished road
Okay, lost again. I posted this in the online course bullitin too, but it seems you guys respond faster.

Quote:
I've got my code working (kind of) - but honestly, I'm kind of lost. I've been following along with the instructions, and ordering the lines as the assignment goes, but I think I'm getting my variables mixed up...

------------------

'Computer Science 40S
'Unit 1: Review Excercise

Dim intNumber As Integer
Dim intTotal As Integer
Dim intRandom As Integer

Private Sub btnClick_Click()

intNumber = intNumber + 1

lblCount.Caption = "Count: " & intNumber

intRandom = 50 <=Rnd * 51 + 50 < 101

lstNumbers.AddItem FormatNumber(intTotal, 1)

intTotal=intTotal + intNumber
lblTotal.Caption="Total:" & vbCrLf & FormatNumber(intTotal, 1)

End Sub
Psychosis is offline   Reply With Quote
Old Dec 5th, 2005, 9:48 PM   #15
Kilo
Expert Programmer
 
Kilo's Avatar
 
Join Date: Nov 2005
Location: In Pink Clam?
Posts: 542
Rep Power: 0 Kilo is an unknown quantity at this point
Send a message via AIM to Kilo
If I may comment, why in the **** would any school waste there time teaching people how to program in visual basic? It did nothing but mess my mind up, back in the day that is . Could someone explain the purpose(please don't say well there are a lot of visual basic programmers needed). Its pathetic to use visual basic to write any program in my OPINION.(not refering to .NET)
__________________
"When in Rome, Do as the Romans Do"
"Beauty is in the eye of the BEER holder"
"Save your breath your going to need it for your blow up doll later"

SearchLores.org
Kilo is offline   Reply With Quote
Old Dec 5th, 2005, 9:50 PM   #16
Mjordan2nd
The Supreme Ruler
 
Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6 Mjordan2nd is on a distinguished road
Quote:
Originally Posted by Kilo
If I may comment, why in the **** would any school waste there time teaching people how to program in visual basic? It did nothing but mess my mind up, back in the day that is . Could someone explain the purpose(please don't say well there are a lot of visual basic programmers needed). Its pathetic to use visual basic to write any program in my OPINION.(not refering to .NET)
They probably use it since it seems to be a bit easier to learn than a lot of other languages, and also since it offers near-immediate results that kids can be proud of. How many kids, aside from enthusiasts, would be proud of making a program that can run on a CLI? Making a GUI would probably be a lot more exciting for them.
__________________
&quot;Every gun that is made, every warship launched, every rocket signifies, in the final sense, a theft from those who hunger and are not fed, from those who are cold and are not clothed. The world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children.&quot; - Dwight D. Eisenhower
Mjordan2nd is offline   Reply With Quote
Old Dec 5th, 2005, 10:25 PM   #17
Kilo
Expert Programmer
 
Kilo's Avatar
 
Join Date: Nov 2005
Location: In Pink Clam?
Posts: 542
Rep Power: 0 Kilo is an unknown quantity at this point
Send a message via AIM to Kilo
Yes that would be a reason to teach 'Visual Basic', but not school. Teaching languages in school is for knowledge of languages used in everyday programming jobs. Teaching a friend visual basic, i would have to agree with you. But as far as teaching them it, to send them out into the real world thinking they know something in my OPINION is messed up.
__________________
"When in Rome, Do as the Romans Do"
"Beauty is in the eye of the BEER holder"
"Save your breath your going to need it for your blow up doll later"

SearchLores.org
Kilo is offline   Reply With Quote
Old Dec 5th, 2005, 11:38 PM   #18
titaniumdecoy
Expert Programmer
 
titaniumdecoy's Avatar
 
Join Date: Nov 2005
Posts: 928
Rep Power: 4 titaniumdecoy is on a distinguished road
Send a message via AIM to titaniumdecoy
I don't know about Visual Basic, but at my school they start off teaching Scheme (a form of Lisp) with a custom API designed by the authors of the book they use. This is a good language choice because it teaches not only class abstraction (like Java) but also functional and syntactic abstraction (for example, you can pass a method as a parameter to another method, or redefine the + symbol). In my opinion, abstraction may be the most important thing to understand for any form of programming, so this is a good choice. Of course, it is not really useful for anything but understanding concepts.
titaniumdecoy is offline   Reply With Quote
Old Dec 6th, 2005, 1:40 AM   #19
lectricpharaoh
SEXY SHOELESS GOD OF WAR!
 
lectricpharaoh's Avatar
 
Join Date: Jun 2005
Location: Wet west coast of Canada
Posts: 1,183
Rep Power: 5 lectricpharaoh will become famous soon enough
Quote:
Originally Posted by Kilo
Yes that would be a reason to teach 'Visual Basic', but not school. Teaching languages in school is for knowledge of languages used in everyday programming jobs. Teaching a friend visual basic, i would have to agree with you. But as far as teaching them it, to send them out into the real world thinking they know something in my OPINION is messed up.
i know you said 'not .NET', but my only VB experience is VB.NET. That said, I feel having basic (pun intended) knowledge is certainly worthwhile.

As a prototyping tool, VB is one of the languages of choice, if not the language. It's just so damn easy and quick to slap something together that would otherwise take a good deal longer. When you sit down with a client, and start whipping up UIs for them, and adding a bit of code to connect to their database so they can see what's happening, they want to see results right away. Having these skills lets you give them that.

Then there's also the fact that many (mainly trivial) applications are not processor intensive. When your program spends 99.99% of its time waiting for the user to press a key or move the mouse, performance really isn't an issue. Size still is, but all the .NET languages compile down fairly small, thanks to the .NET framework.

I agree wholeheartedly that many larger real-world applications cannot be written in VB and expected to meet performance requirements. I also agree that VB allows for lazy coding practices, what with the autoformatting and 'intellisense' thing going on. Still, I believe it's a language that definitely has its place in the industry, and as a teaching tool, what Mjordan2nd said is hard to overstress. Seeing immediate or short-term success is a strong motivating factor in learning (or any endeavor, for that matter). Why do you think one of the major factors of project success is having small milestones/early deliverables? It keeps the team motivated.
__________________
And once again, Probability proves itself willing to sneak into a back alley and service Drama as would a copper-piece harlot.
- Vaarsuvius, Order of the Stick
lectricpharaoh is offline   Reply With Quote
Old Dec 6th, 2005, 11:59 PM   #20
Kilo
Expert Programmer
 
Kilo's Avatar
 
Join Date: Nov 2005
Location: In Pink Clam?
Posts: 542
Rep Power: 0 Kilo is an unknown quantity at this point
Send a message via AIM to Kilo
@lectricpharaoh: I would agree with you now that we are not referring to .NET lol. If you are that into VB .NET (for RAD and Simplicity) I highly recommend (in opinion) you drop VB and take up C#.
__________________
"When in Rome, Do as the Romans Do"
"Beauty is in the eye of the BEER holder"
"Save your breath your going to need it for your blow up doll later"

SearchLores.org
Kilo is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 6:27 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC