Posts Tagged ‘How to’

How to replace one or more whitespace in vb.net

  1. Imports System.Text.RegularExpressions</p>
  2. Module Example
  3.    Public Sub Main()
  4.       Dim input As String = "This is   text with   far  too   much   " +
  5.                             "whitespace."
  6.       Dim pattern As String = "\s+"
  7.       Dim replacement As String = " "
  8.       Dim rgx As New Regex(pattern)
  9.       Dim result As String = rgx.Replace(input, replacement)
  10.       Console.WriteLine("Original String: {0}", input)
  11.       Console.WriteLine("Replacement String: {0}", result)
  12.    End Sub
  13. End Module

, , , ,

No Comments


How to get Julian Date format in .Net

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

See Julain Day
Julian Date in Excel

, ,

No Comments


How to rename a file
  1. function MoveFile()
  2.    dim OrigFilename as string = "myfile.pdf"
  3.  
  4.    Dim fi As New FileInfo(OrigFilename)
  5.    
  6.    fi.MoveTo("myNewFile.pdf")
  7.  
  8. end function

, , ,

No Comments


How to Install .tar

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 -C .

, , ,

No Comments


How to Install .bin

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

, ,

2 Comments


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;

  1. Select Listbox control, in the property set the DrawMode to OwnerDrawVariable
  2. In MeasureItem event of the listbox, add the code below

    e.ItemHeight = 25

  3. Add this code to the DrawItem Event
    1.     Private Sub ListBox1_DrawItem(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles ListBox1.DrawItem
    2.         e.DrawBackground()
    3.  
    4.         Dim drawbrush As Brush
    5.  
    6.         If (e.State And DrawItemState.Selected) = DrawItemState.Selected Then
    7.             drawbrush = Brushes.White
    8.         Else
    9.             drawbrush = Brushes.Black
    10.         End If
    11.  
    12.         Dim s As String
    13.  
    14.         s = CType(sender, ListBox).Items(e.Index).ToString
    15.  
    16.         e.Graphics.DrawString(s, CType(sender, Control).Font, drawbrush, e.Bounds.X, e.Bounds.Y)
    17.  
    18.  
    19.     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.

, , ,

No Comments


How to create Temporary filename in vb.Net
  1. Private Sub TempFile()
  2.      Dim sTempFileName AsString = System.IO.Path.GetTempFileName()
  3.      Dim fsTemp AsNew System.IO.FileStream(sTempFileName, IO.FileMode.Create)
  4.  
  5.      MessageBox.Show(sTempFileName)
  6.  
  7.      'write data to the temp file
  8.      fsTemp.Close()
  9.  
  10.      System.IO.File.Delete(sTempFileName)
  11.  End Sub

, , ,

No Comments


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))

}

, , ,

No Comments


How to add a Line Break in T-SQL Query

char(13) + char(10)

example:

<pre lang=”vb” >

PRINT ‘LINE ONE ‘ + char(13) + char(10) + ‘LINE TWO’

</pre>

Read Forum

,

No Comments


How to Allow Explicit Values to be inserted into the identity column of a table

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

, , ,

1 Comment



SetPageWidth