-
Feb 20th, 2015, 07:58 PM
#1
Thread Starter
Lively Member
[RESOLVED] Shorten Code
I would like to make my code shorter.
I would like to make it so instead of textbox1.text it would be txtbx1.txt.
How can I do this? I tried doing some DIM's, but it didn't work.
-
Feb 20th, 2015, 08:01 PM
#2
Re: Shorten Code
TextBox1 is the name of the control, which you generally set in the properties of the control in the designer. In fact, it's a good idea to always rename your controls rather than using the default name, so shorten them as much as you like.
However, there is no advantage to shortening the names, so it is best to use names that are long enough that you can identify the controls easily. After all, the controls all show up in intellisense, so you generally never type the whole control name.
My usual boring signature: Nothing
-
Feb 20th, 2015, 08:02 PM
#3
Thread Starter
Lively Member
Re: Shorten Code
So how would I change the control?
-
Feb 20th, 2015, 08:08 PM
#4
Re: Shorten Code
In the properties window when in the form designer is the best and easiest way.
My usual boring signature: Nothing
-
Feb 20th, 2015, 08:13 PM
#5
Thread Starter
Lively Member
Re: Shorten Code
I see what your saying. But I want to change other things. for example, console.writeline to cnsl.wl. I would like it to change thing that do not have properties
-
Feb 20th, 2015, 08:20 PM
#6
Re: Shorten Code
you cant or ver would eventhink about it.
-
Feb 20th, 2015, 08:26 PM
#7
Thread Starter
Lively Member
Re: Shorten Code
Yes you can. I've seen it before
-
Feb 20th, 2015, 08:30 PM
#8
Re: Shorten Code
I suggest you spend some time on msdn asking why?
console.writeline https://msdn.microsoft.com/en-us/lib...code-snippet-1
-
Feb 20th, 2015, 09:53 PM
#9
Re: Shorten Code
You can by creating a wrapper class, e.g.
Code:
Option Strict On
Option Explicit On
Public Class cnsl
Public Shared Sub wl(l As String)
Console.WriteLine(l)
End Sub
Public Shared Function rl() As String
Return Console.ReadLine
End Function
End Class
But do you really need so?!
-
Feb 20th, 2015, 10:21 PM
#10
Re: Shorten Code
Originally Posted by 4x2y
You can by creating a wrapper class, e.g.
Code:
Option Strict On
Option Explicit On
Public Class cnsl
Public Shared Sub wl(l As String)
Console.WriteLine(l)
End Sub
Public Shared Function rl() As String
Return Console.ReadLine
End Function
End Class
But do you really need so?!
you are missing my point. WHY!!!!
*edit just seen bottom lines
-
Feb 20th, 2015, 10:35 PM
#11
Thread Starter
Lively Member
Re: Shorten Code
Thank you
-
Feb 20th, 2015, 11:07 PM
#12
Thread Starter
Lively Member
Re: Shorten Code
Do you know if I have to have strict and explicit on?
-
Feb 21st, 2015, 12:40 AM
#13
Re: Shorten Code
Originally Posted by kshadow22
Do you know if I have to have strict and explicit on?
They are optional but it is highly recommended to always turn them on, because they will save a lot of debugging time, specially "Explicit On"
Last edited by 4x2y; Feb 21st, 2015 at 12:54 AM.
-
Feb 21st, 2015, 01:14 AM
#14
Re: [RESOLVED] Shorten Code
Why would you want to do this OP? This will effect the readability of your code, and in my opinion, it's a terrible idea.
Why would anyone want cnsl.wl("")
that it an meaningful name. Console.WriteLine() is much clearer and read able. Honestly just leave it the way it is.
-
Feb 21st, 2015, 01:17 AM
#15
Thread Starter
Lively Member
Re: [RESOLVED] Shorten Code
When I get deep into coding, I would like just to be able to type codes with the fewest amount of codes. Especially when I am dealing with encryptions.
-
Feb 21st, 2015, 02:36 PM
#16
Re: [RESOLVED] Shorten Code
Originally Posted by kshadow22
When I get deep into coding, I would like just to be able to type codes with the fewest amount of codes. Especially when I am dealing with encryptions.
Not by shortening the actual class names and methods. You should leave them as they are, but you should aim to write readable and neat code. Condensing something like Console.WriteLine() into cnsl.wl("") is just the worst idea I've ever heard since I started programming. What if you were to give that code to another programmer to read? Don't adopt these bad habits. I don't see what encryption has to do with this
-
Feb 21st, 2015, 04:38 PM
#17
Re: [RESOLVED] Shorten Code
Originally Posted by kshadow22
When I get deep into coding, I would like just to be able to type codes with the fewest amount of codes. Especially when I am dealing with encryptions.
so all of us who have been programmers for years are wrong? dealing with encryptions..... maybe in 5 years you might be.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|