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.
Printable View
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.
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.
So how would I change the control?
In the properties window when in the form designer is the best and easiest way.
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
you cant or ver would eventhink about it.
Yes you can. I've seen it before
I suggest you spend some time on msdn asking why?
console.writeline https://msdn.microsoft.com/en-us/lib...code-snippet-1
You can by creating a wrapper class, e.g.
But do you really need so?!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
Thank you :)
Do you know if I have to have strict and explicit on?
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.
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