Posts Tagged ‘How to’
How to replace one or more whitespace in vb.net
Posted by: admin in .NET, Regular Expression (NET) on September 1st, 2011
-
Imports System.Text.RegularExpressions</p>
-
Module Example
-
Public Sub Main()
-
Dim input As String = "This is text with far too much " +
-
"whitespace."
-
Dim pattern As String = "\s+"
-
Dim replacement As String = " "
-
Dim rgx As New Regex(pattern)
-
Dim result As String = rgx.Replace(input, replacement)
-
Console.WriteLine("Original String: {0}", input)
-
Console.WriteLine("Replacement String: {0}", result)
-
End Sub
-
End Module
How to get Julian Date format in .Net
Posted by: admin in .NET, Date Formatting on June 8th, 2009
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
MessageBox.Show(Strings.Format(Date.Today, “yy”) & Date.Today.DayOfYear.ToString.PadLeft(3, “0″))
End Sub
End Class
How to rename a file
-
function MoveFile()
-
dim OrigFilename as string = "myfile.pdf"
-
-
Dim fi As New FileInfo(OrigFilename)
-
-
fi.MoveTo("myNewFile.pdf")
-
-
end function
How to Install .tar
Posted by: admin in Installation, Ubuntu on May 21st, 2009
TAR files are generally not compressed; simply added together into a single file. Most programs that will handle .ZIP or other archive formats will also handle .TAR files.
1. Open Terminal
2. Type the command, sudo tar -xjvf
How to Install .bin
Posted by: admin in Installation, Ubuntu on May 21st, 2009
To Install the .bin file extension in Ubuntu;
First, you have to make the .bin file executable,
1. Open Terminal (Applications->Accessories->Terminal).
2. Change the current directory if necessary, use cd command to change the directory.
3. sudo chmod +x
Finally, run the .bin file
1. In Terminal, type sudo
How to change the Height of Listbox Item
To change the height of the listbox items you have to customize the listbox by drawing the each item manually, to do this;
- Select Listbox control, in the property set the DrawMode to OwnerDrawVariable
- In MeasureItem event of the listbox, add the code below
e.ItemHeight = 25
- Add this code to the DrawItem Event
-
Private Sub ListBox1_DrawItem(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles ListBox1.DrawItem
-
e.DrawBackground()
-
-
Dim drawbrush As Brush
-
-
If (e.State And DrawItemState.Selected) = DrawItemState.Selected Then
-
drawbrush = Brushes.White
-
Else
-
drawbrush = Brushes.Black
-
End If
-
-
Dim s As String
-
-
s = CType(sender, ListBox).Items(e.Index).ToString
-
-
e.Graphics.DrawString(s, CType(sender, Control).Font, drawbrush, e.Bounds.X, e.Bounds.Y)
-
-
-
End Sub
-
Note: The difference between the two owner-drawn options is that with fixed drawing each item in the list is the standard size (typically 13 px), and with OwnerDrawVariable you can specify the height for each item independently.
How to create Temporary filename in vb.Net
-
Private Sub TempFile()
-
Dim sTempFileName AsString = System.IO.Path.GetTempFileName()
-
Dim fsTemp AsNew System.IO.FileStream(sTempFileName, IO.FileMode.Create)
-
-
MessageBox.Show(sTempFileName)
-
-
'write data to the temp file
-
fsTemp.Close()
-
-
System.IO.File.Delete(sTempFileName)
-
End Sub
How to Insert Xml Node from One document to another XML Document in vb.net
If you want to insert xmlnode from one document to another, you have to import the xmlnode.
dim xmlDoc01 as XMLDocument
dim xmlDoc02 as XMLDocument
private sub InsertNod() ’insert xmlnode from xmlDoc01 to xmlDoc02
{
xmldoc01.AppendChild(xmlDoc01.ImportNode(xmlDoc01.ChildNodes(0), true))
}
How to add a Line Break in T-SQL Query
Posted by: admin in MS SQL Server on April 23rd, 2009
char(13) + char(10)
example:
<pre lang=”vb” >
PRINT ‘LINE ONE ‘ + char(13) + char(10) + ‘LINE TWO’
</pre>
How to Allow Explicit Values to be inserted into the identity column of a table
Posted by: admin in MS SQL Server on March 31st, 2009
Allows explicit values to be inserted into the identity column of a table
Syntax
SET IDENTITY_INSERT [ database. [ owner. ] ] { table } { ON | OFF }
Arguments
database
Is the name of the database in which the specified table resides.
owner
Is the name of the table owner.
table
Is the name of a table with an identity column.
Remarks
At any time, only one table in a session can have the IDENTITY_INSERT property set to ON. If a table already has this property set to ON, and a SET IDENTITY_INSERT ON statement is issued for another table, Microsoft® SQL Server™ returns an error message that states SET IDENTITY_INSERT is already ON and reports the table it is set ON for.
If the value inserted is larger than the current identity value for the table, SQL Server automatically uses the new inserted value as the current identity value.
The setting of SET IDENTITY_INSERT is set at execute or run time and not at parse time.
Permissions
Execute permissions default to the sysadmin fixed server role, and the db_owner and db_ddladmin fixed database roles, and the object owner.
Examples
This example creates a table with an identity column and shows how the SET IDENTITY_INSERT setting can be used to fill a gap in the identity values caused by a DELETE statement.
– Create products table.
CREATE TABLE products (id int IDENTITY PRIMARY KEY, product varchar(40))
GO
– Inserting values into products table.
INSERT INTO products (product) VALUES (‘screwdriver’)
INSERT INTO products (product) VALUES (‘hammer’)
INSERT INTO products (product) VALUES (‘saw’)
INSERT INTO products (product) VALUES (‘shovel’)
GO
– Create a gap in the identity values.
DELETE products
WHERE product = ‘saw’
GO
SELECT *
FROM products
GO
– Attempt to insert an explicit ID value of 3;
– should return a warning.
INSERT INTO products (id, product) VALUES(3, ‘garden shovel’)
GO
– SET IDENTITY_INSERT to ON.
SET IDENTITY_INSERT products ON
GO
– Attempt to insert an explicit ID value of 3
INSERT INTO products (id, product) VALUES(3, ‘garden shovel’).
GO
SELECT *
FROM products
GO
– Drop products table.
DROP TABLE products
GO
Source: http://msdn.microsoft.com/en-us/library/aa259221(SQL.80).aspx