Go Back   Gaming Gutter > Non-Gaming > Programming > Source Code


Source Code - Have a source code/project files you want to post? Do so here.

» Site Navigation
» Home
» FAQ
» Log in
User Name:

Password:

Not a member yet?
Register Now!
» Advertisement
» Recent Threads
Go to first new post Best current TV show
11-13-2008 10:07 AM
Last post by Dday
Today 10:49 PM
18 Replies, 125 Views
Go to first new post The best browser
11-13-2008 06:35 PM
Last post by Dday
Today 10:48 PM
60 Replies, 361 Views
Go to first new post Soo.... Im gone for like...
Today 10:44 PM
Last post by ASHTEHCOMMIE
Today 10:44 PM
0 Replies, 1 Views
Go to first new post Almost all types of...
Today 12:09 AM
Last post by l_royalty_l
Today 10:42 PM
6 Replies, 45 Views
Go to first new post Heather wants to kill a...
Today 06:49 PM
Last post by Benita Mussolina
Today 10:29 PM
25 Replies, 109 Views
Reply
 
LinkBack Thread Tools Display Modes

 [VB6] The hard way
Old 02-10-2007, 12:13 PM   #1 (permalink)
Underground

Male Nitech is offline
 
Nitech's Avatar
 
Join Date: Jan 2007
Location: Russia
Age: 14
Posts: 226
GPoints: 31
iTrader: 0 / 0%
Nitech Is gaining popularity
Rep Power: 6
[VB6] The hard way

Here I will be posting 'the hard ways' of doing simple things. For example getting a string from a textbox to a label and such.

The first Ill post with the gettings string to label from textbox.
So, you have a textbox a label and a button right? Great! Thats all you need.
Here is the source to do it the hard way:
Code:
Label2.Caption = ""
Dim strText As String
Dim strLetter As String
Dim lnFirst, lnLast As Long
Dim Result As String
Dim strLastLetter As String
strText = Text1.Text
lnFirst = 1
lnLast = Len(strText)
If lnLast < 1 Then Exit Sub
Do While (lnFirst <> Len(strText))
    strLetter = VBA.Left(strText, lnFirst)
    lnFirst = lnFirst + 1
    Result = strLetter
    strLetter = ""
    Result = ""
    Label2.Caption = Label2.Caption & Result
Loop
If lnFirst = lnLast Then
    strLastLetter = VBA.Left(strText, lnLast)
    Result = strLastLetter
    Label2.Caption = Label2.Caption & Result
End If
End Sub
This is hell long. But it works right? YES, IT DOES.

Now, how to do it the easy way:
Code:
Private Sub Command2_Click()
Label3.Caption = Text2.Text
End Sub
There is a difference right?

I was making this code, and discluded the "Result = """ to have more fun.

Unfortunately I couldnt do anything with that so I just put it in and everything worked.

Anyway I hope you learn from this. And I will be positng more hard ways to do things later.
__________________

Quote:
Vlad says:
LEL 20 DUELRZ PLIZ ;O
Ryan says:
HAHA NO LOL
Vlad says:
You like men.
^Lesson learnt.

Last edited by Nitech; 02-10-2007 at 12:25 PM. Reason: Indented code ;)
  Reply With Quote

 Re: [VB6] The hard way
Old 02-10-2007, 01:01 PM   #2 (permalink)
Full Member

Male Laser Wave is offline
 
Join Date: Oct 2006
Posts: 37
GPoints: 20
iTrader: 0 / 0%
Laser Wave Is gaining popularity
Rep Power: 7
Re: [VB6] The hard way

What's the point in this?

Nobody would be stupid enough to even attempt the first example...
  Reply With Quote

 Re: [VB6] The hard way
Old 02-10-2007, 01:05 PM   #3 (permalink)
Underground

Male Nitech is offline
 
Nitech's Avatar
 
Join Date: Jan 2007
Location: Russia
Age: 14
Posts: 226
GPoints: 31
iTrader: 0 / 0%
Nitech Is gaining popularity
Rep Power: 6
Re: [VB6] The hard way

Obviously you don't get the meaning of this thread. This thread is not source code that you might actually use, but its material that you can refer to when thinking outside the box. You have to be a good programmer to Get something as simple as that to turn it into bloated code.
__________________

Quote:
Vlad says:
LEL 20 DUELRZ PLIZ ;O
Ryan says:
HAHA NO LOL
Vlad says:
You like men.
^Lesson learnt.
  Reply With Quote

 Re: [VB6] The hard way
Old 02-10-2007, 01:22 PM   #4 (permalink)
Full Member

Male Laser Wave is offline
 
Join Date: Oct 2006
Posts: 37
GPoints: 20
iTrader: 0 / 0%
Laser Wave Is gaining popularity
Rep Power: 7
Re: [VB6] The hard way

Quote:
Originally Posted by UB3R1337H4X View Post
You have to be a good programmer to Get something as simple as that to turn it into bloated code.
It doesn't take a good programmer to do something pointless...
  Reply With Quote

 Re: [VB6] The hard way
Old 02-10-2007, 03:07 PM   #5 (permalink)
screamdreams
Guest

 
Posts: n/a
GPoints: 0 [Check]
iTrader: / %
Rep Power:
Re: [VB6] The hard way

I my opinion its a good exercise to do when you have time. Teaches you to approach problems from a different angle. I am not sure if I would release it as source , but it is interesting to see how different people think and I am sure he is trying to stimulate the section and give some ideas on some good mental exercises.

  Reply With Quote

 Re: [VB6] The hard way
Old 02-10-2007, 03:58 PM   #6 (permalink)
Full Member

Male padora is offline
 
Join Date: Nov 2006
Posts: 15
GPoints: 20
iTrader: 0 / 0%
padora Is gaining popularity
Rep Power: 0
Re: [VB6] The hard way

Quote:
Originally Posted by screamdreams View Post
I my opinion its a good exercise to do when you have time. Teaches you to approach problems from a different angle. I am not sure if I would release it as source , but it is interesting to see how different people think and I am sure he is trying to stimulate the section and give some ideas on some good mental exercises.

Wrong again, it's pointless. A programmer's job is to find the most efficient way to do it while keeping their source looking clean. If I saw that junk in one's source I think I'd puke.
  Reply With Quote

 Re: [VB6] The hard way
Old 02-10-2007, 05:07 PM   #7 (permalink)
screamdreams
Guest

 
Posts: n/a
GPoints: 0 [Check]
iTrader: / %
Rep Power:
Re: [VB6] The hard way

Notice I said exercise not good coding there is a difference, I would never in a million years code like that, but I may do it just for fun to see how I could do it a different way.
I would Never use it or release it though.
Most people get stuck on what in the end is an easy task. This is because they are use to having all the functions or source displayed for them. They do not understand the concepts of how the function works. In the exercise that hes performing hes making a harder replacement for something simple, in the process of doing this hopefully he is gaining some experience in how to approach a problem and solve it(not having the answers just given to him). That is why this is a good exercise. I do logic and math puzzles for a hobby though so maybe thats why I can appreciate this.

I like you would also puke if I actually seen someone releasing that as source :P.
It's just a practice exercise and thats all it is.
Not flaming(I actually respect you as a programmer) but whats with the wrong again? Where else have you shown me to be wrong? Not that I have not been wrong on more than a few occasions, I just do not remember you pointing them out to me. Which if I am I wish you would so that I can learn from my mistakes . On this subject though neither of us are wrong it is an opinion on how to learn. Now if it was the actual code he was using to perform this than yeah it would be pointless and you would have no argument from me.

In closing I would like to add that you know how to program, you know how to logically come up with a solution to a problem based on your understanding of the concepts. Some people don't so they practice. I judge, myself to be a rather good artist. So if I were to use your thinking I would see it as pointless for some one to practice drawing doodles.
  Reply With Quote

 Re: [VB6] The hard way
Old 02-10-2007, 09:58 PM   #8 (permalink)
Underground

Male Nitech is offline
 
Nitech's Avatar
 
Join Date: Jan 2007
Location: Russia
Age: 14
Posts: 226
GPoints: 31
iTrader: 0 / 0%
Nitech Is gaining popularity
Rep Power: 6
Re: [VB6] The hard way

Thanks nitemares, someone that actually gets the point of this..
__________________

Quote:
Vlad says:
LEL 20 DUELRZ PLIZ ;O
Ryan says:
HAHA NO LOL
Vlad says:
You like men.
^Lesson learnt.
  Reply With Quote

 Re: [VB6] The hard way
Old 02-12-2007, 09:20 AM   #9 (permalink)
liurr90
Guest

 
Posts: n/a
GPoints: 0 [Check]
iTrader: / %
Rep Power:
Re: [VB6] The hard way

I don't quite see the point to this either. This isn't the "hard way" at all. This simply an unnecessary method of doing what could be done in a single line. All you're doing is tearing apart a string and putting it back together without making any changes to it at all whatsoever.

Professional programmers wouldn't do this because it is completely inefficient. Newbie programmers wouldn't do this because they wouldn't know how to. No programmer would do this because there's no point in doing so.
  Reply With Quote

 Re: [VB6] The hard way
Old 02-12-2007, 09:21 AM   #10 (permalink)
jeffrey_978
Guest

 
Posts: n/a
GPoints: 0 [Check]
iTrader: / %
Rep Power:
Re: [VB6] The hard way

Whats the whole point of this?
  Reply With Quote
Reply

Bookmarks



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
Trackbacks are On
Pingbacks are On
Refbacks are On

Powered by vBadvanced CMPS v3.0 RC2

All times are GMT -7. The time now is 10:49 PM.


vBulletin skin developed by: eXtremepixels
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The contents of this webpage are copyright © 2006-2008 GamingGutter.com. All Rights Reserved.

Page generated in 0.13183498 seconds (100.00% PHP - 0% MySQL) with 19 queries