How to get the current path using VBScript

To get the current path using VBScript you can use the snippet below.

Samples

VBScript Sample

If you have any questions or suggestions feel free to rate this snippet, post a comment or Contact Us via Email.

Related links:

Please rate this snippet

How to deep copy a IList in C# and VB.NET

To deep copy a IList in C# and VB.NET you can use the snippet.

Sample C#

public static IList<T> Clone<T>(IList<T> listToClone) where T : ICloneable
{
	return listToClone.Select(item => (T)item.Clone()).ToList();
}

Sample VB.NET

Public Shared Function Clone(Of T As ICloneable)(listToClone As IList(Of T)) As IList(Of T)
	Return listToClone.[Select](Function(item) DirectCast(item.Clone(), T)).ToList()
End Function

Please rate this snippet

What is the difference between mutable and immutable in C# and VB.NET

What is the difference between a mutable and immutable string in C# and VB.NET?

  • A mutable string can be changed.
  • An immutable string cannot be changed.
  • Mutable is the english word for can change. Immutable is the english word for cannot change.

    if you alter a String, you are creating a new string object internally. So String is immutable. If you alter a StringBuilder no new Objects are created internally so, StringBuilder is mutable.

    Please rate this snippet

    IsNull extension method for C# and VB.NET

    You can use the IsNull Extension method by using the snippet below.

    Sample C#

    public static bool IsNull(this object source)
    {
         return source == null;
    }
    

    Sample VB.NET

    <System.Runtime.CompilerServices.Extension> _
    Public Shared Function IsNull(source As Object) As Boolean
    	Return source Is Nothing
    End Function
    

    As always, this extension method has been added to the Github Fesslersoft.Extensions Repository

    Please rate this snippet

    How to query a DataTable using LINQ in C# and VB.NET

    To query a DataTable using LINQ in C# and VB.NET you can use the snippet below.
    In order to use the snippet, you need to reference System.Data.DataSetExtensions.

    Sample C#

    var resultData = (from myDataRow in myDataTable.AsEnumerable() where myDataRow.Field<Int32>("Fieldname") == 1 select myRow);
    

    Sample VB.NET

    Dim resultData = (From myDataRow In myDataTable.AsEnumerable() Where myDataRow.Field(Of Int32)("Fieldname") = 1myRow)
    

    Please rate this snippet

    How to remove an element using Javascript

    To remove an element using javascript, you can use one of the following snippets.

    Sample Javascript

    //usage document.getElementById("ElementId").remove();
    Element.prototype.remove = function() {
    	this.parentElement.removeChild(this);
    }
    

    Sample Javascript

    //usage document.getElementsByClassName("Elements").remove();
    NodeList.prototype.remove = HTMLCollection.prototype.remove = function() {
    	for(var index = 0, length = this.length; index < length; index++) {
    		if(this[index] && this[index].parentElement) {
    			this[index].parentElement.removeChild(this[index]);
    		}
    	}
    }
    

    removeChild() is the only method supported by the DOM to remove a element in Javascript (see -> Mozilla MDN Node.removeChild()).

    Please rate this snippet

    How to set a Property Value by Name in C# and VB.NET

    To set a Property Value by Name in C# and VB.NET you can use the following snippet.

    Sample C#

    public static bool SetPropertyByName(this Object obj, string name, Object value)
    {
    	var prop = obj.GetType().GetProperty(name, BindingFlags.Public | BindingFlags.Instance);
    	if (null == prop || !prop.CanWrite) return false;
    	prop.SetValue(obj, value, null);
    	return true;
    }
    

    Sample VB.NET

    Public Shared Function SetPropertyValueByName(obj As [Object], name As String, value As [Object]) As Boolean
    	Dim prop = obj.[GetType]().GetProperty(name, BindingFlags.[Public] Or BindingFlags.Instance)
    	If prop Is Nothing OrElse Not prop.CanWrite Then
    		Return False
    	End If
    	prop.SetValue(obj, value, Nothing)
    	Return True
    End Function
    

    Please rate this snippet

    How to set the start location of FolderBrowserDialog in C# and VB.NET

    To set the start location of FolderBrowserDialog in C# and VB.NET you can use the following snippet.
    To do so, simply set the SelectedPath Value to the path you want.

    Sample C#

    MyFolderBrowserDialog.SelectedPath = @"C:\Test";
    

    Sample VB.NET

    MyFolderBrowserDialog.SelectedPath = "C:\Test"
    

    Please rate this snippet