You are viewing our Forum Archives. To view or take place in current topics click here.
[VB.NET/C#] Skittle's Library
Posted:

[VB.NET/C#] Skittle's LibraryPosted:

Skittle
  • Download King
Status: Offline
Joined: Aug 20, 20149Year Member
Posts: 6,813
Reputation Power: 413
Status: Offline
Joined: Aug 20, 20149Year Member
Posts: 6,813
Reputation Power: 413

This is nothing huge, just a .dll with some functions and methods i have been compiling together. If you have any suggestions or additions I could make to this .DLL then please feel free to reply with your ideas!

Extension Methods can be used as an extension for a variable, or a regular procedure call like this:

myVariable.myMethod([any other parameters])
OR
myMethod(myVariable, [any other parameters])

Download:

[ Register or Signin to view external links. ]
[ Register or Signin to view external links. ]


Here is a list of them all:

[String].IsOnlyNumeric

Extension method for Strings
Return Type: Boolean

Checks a String to see if it contains any characters other than numbers, including spaces and returns a Boolean value depending on the result.

Example:

Dim myString As String = "abcd1234"
MsgBox(myString.IsOnlyNumeric())
'This will print "False" as there non numerical characters in the String


Example 2:

Dim myString As String = "1234"
MsgBox(myString.IsOnlyNumeric())
'This will print "True" as there are only numbers in the string.

Example 3:

Dim myString As String = "1 2 3 4"
MsgBox(myString.IsOnlyNumeric)
'This will print "False" as there are spaces in the string.



[Boolean].Swap

Extension method for Booleans
Return Type: Boolean

Returns and changes the value of a Boolean from True --> False and vice-versa.

Example:

Dim myBool As Boolean = False
MsgBox(myBool)
'prints out "False"
MsgBox(myBool.Swap()) 'changes the value from False --> True
'prints out "True"
'the value of myBool was changed from False --> True instead of just returned.
MsgBox(myBool)
'Prints out "True"



[Integer].IsEven

Extension method for Integers
Return Type: Boolean

Returns a Boolean value depending on if the Integer is even or not.

Example:

Dim myInt As Integer = 2
MsgBox(myInt.IsEven)
'this will print "True"

myInt = 3

MsgBox(myInt.IsEven)
'this will print "False"



[Integer].IsOdd

Extension method for Integers
Return Type: Boolean

Returns a Boolean value depending on if the Integer is odd or not.

Example:

Dim myInt As Integer = 1
MsgBox(myInt.IsOdd)
'this will print "True"

myInt = 2

MsgBox(myInt.IsOdd)
'this will print "False"



[Form].LockFormSize

Locks the form size to the size set when creating the form or to the paramater-passed Drawing.Size, users cannot resize the form during runtime.

Example:

'form size is set to 400, 400 when designing form
LockFormSize(Form1)
'locks the form size to 400, 400 (the size set during the designing of the form) and prevents the user from re-sizing the form while the program is running


Example 2:

LockFormSize(Form1, New Drawing.Size(450, 450)) 'or Form1.LockFormSize(New Drawing.Size(450, 400))
'sets the form size to 450 x 450 ad stops the user from being able to change it while the program is running



[String].ReverseString

Extension method for Strings
Return Type: String

Returns a String with the characters backwards.

Example:

Dim myString As String = "Skittle"
MsgBox(myString.ReverseString)
'prints out "elttikS"



[String].getChar

Extension method for Strings
Return Type: Char

Returns 1 character from the specified String.

Example:

Dim myString As String = "Skittle"
MsgBox(myString.getChar(2)) 'or MsgBox(getChar(myString, 2)
'prints out "k"


The following 2 users thanked Skittle for this useful post:

Imp (12-08-2014), Normality (11-27-2014)
#2. Posted:
Status: Offline
Joined: Mar 17, 201113Year Member
Posts: 3,970
Reputation Power: 3081
Status: Offline
Joined: Mar 17, 201113Year Member
Posts: 3,970
Reputation Power: 3081
Great Topic!

Keep it up dude.
#3. Posted:
vRice
  • 2 Million
Status: Offline
Joined: Dec 17, 201112Year Member
Posts: 823
Reputation Power: 41
Status: Offline
Joined: Dec 17, 201112Year Member
Posts: 823
Reputation Power: 41
Returns 1 character from the specified String.

So does testString[int] (C# Master Race! haha) ;- )

But still, these are useful and simple to use, +Rep.
#4. Posted:
Skittle
  • 1000 Thanks
Status: Offline
Joined: Aug 20, 20149Year Member
Posts: 6,813
Reputation Power: 413
Status: Offline
Joined: Aug 20, 20149Year Member
Posts: 6,813
Reputation Power: 413
vRice wrote Returns 1 character from the specified String.

So does testString[int] (C# Master Race! haha) ;- )

But still, these are useful and simple to use, +Rep.

Haha, I just have this in there as I'm pretty sure you can't do it in VB
#5. Posted:
vRice
  • TTG Master
Status: Offline
Joined: Dec 17, 201112Year Member
Posts: 823
Reputation Power: 41
Status: Offline
Joined: Dec 17, 201112Year Member
Posts: 823
Reputation Power: 41
-Skittle wrote
vRice wrote Returns 1 character from the specified String.

So does testString[int] (C# Master Race! haha) ;- )

But still, these are useful and simple to use, +Rep.

Haha, I just have this in there as I'm pretty sure you can't do it in VB


I can't remember if you can either, been so long since I last did VB haha :p
#6. Posted:
Skittle
  • V5 Launch
Status: Offline
Joined: Aug 20, 20149Year Member
Posts: 6,813
Reputation Power: 413
Status: Offline
Joined: Aug 20, 20149Year Member
Posts: 6,813
Reputation Power: 413
vRice wrote
-Skittle wrote
vRice wrote Returns 1 character from the specified String.

So does testString[int] (C# Master Race! haha) ;- )

But still, these are useful and simple to use, +Rep.

Haha, I just have this in there as I'm pretty sure you can't do it in VB


I can't remember if you can either, been so long since I last did VB haha :p

I'm starting to move over to C# so I'll add some functions that will help with this language
#7. Posted:
Imp
  • Shoutbox Hero
Status: Offline
Joined: Jan 01, 201113Year Member
Posts: 1,957
Reputation Power: 401
Status: Offline
Joined: Jan 01, 201113Year Member
Posts: 1,957
Reputation Power: 401
Firstly, this is a really good post, I am glad you have taken time to post here to get the section more active!

I would like to add that I am only posting this to expand knowledge, not to critcize you in any way

[String].IsOnlyNumeric

IsNumeric(String) in VB

[String].All(Char.IsDigit); in C#

[Boolean].Swap

Not [Boolean] in VB

![Boolean] in C#


[Integer].IsEven and [Integer].IsOdd

[Integer] Mod 2 in VB

[Integer] % 2 in C#

(Put in an If Statement and see if 0 (for even) otherwise odd)


[Form].LockFormSize

[ Register or Signin to view external links. ]

In Designer or

me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.[Border Style from Enumerator] in VB

this.FormBorderStyle = FormBorderStyle.[Border Style from Enumerator]; in C#


[String].ReverseString

Can't fault this idea


[String].getChar

[String].Chars([zero based array index]) in VB

As vRice said [String][int] in C#


As I said at the top, this is purely spreading the knowledge, please continue to add more and here is some Rep!!
#8. Posted:
Skittle
  • Video King
Status: Offline
Joined: Aug 20, 20149Year Member
Posts: 6,813
Reputation Power: 413
Status: Offline
Joined: Aug 20, 20149Year Member
Posts: 6,813
Reputation Power: 413
Imp wrote Firstly, this is a really good post, I am glad you have taken time to post here to get the section more active!

I would like to add that I am only posting this to expand knowledge, not to critcize you in any way

[String].IsOnlyNumeric

IsNumeric(String) in VB

[String].All(Char.IsDigit); in C#

[Boolean].Swap

Not [Boolean] in VB

![Boolean] in C#


[Integer].IsEven and [Integer].IsOdd

[Integer] Mod 2 in VB

[Integer] % 2 in C#

(Put in an If Statement and see if 0 (for even) otherwise odd)


[Form].LockFormSize

[ Register or Signin to view external links. ]

In Designer or

me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.[Border Style from Enumerator] in VB

this.FormBorderStyle = FormBorderStyle.[Border Style from Enumerator]; in C#


[String].ReverseString

Can't fault this idea


[String].getChar

[String].Chars([zero based array index]) in VB

As vRice said [String][int] in C#


As I said at the top, this is purely spreading the knowledge, please continue to add more and here is some Rep!!

Thanks for the improvements I simply made these to ease programming by shortening the code slightly and for simplicity
Thanks!
Jump to:
You are viewing our Forum Archives. To view or take place in current topics click here.