SETHA SITE INFORMATION

  • Increase font size
  • Default font size
  • Decrease font size
SETHA SITE INFORMATION

Create Dictionary English-Khmer in Visual Basic 6

E-mail Print PDF
This article shows you how to create English-Khmer dictionary in Visual Basic 6 and provides you the full source code.
Some points to take note in this example:
  • Using Microsoft Access to store dictionary words list (Protected Password: 12345)
  • Using RichTextBox control
  • Using Color Option
  • Including Hang Man Game from English Word List

Download Source Code Here
 

How to Open File Location using C# 2008?

E-mail Print PDF
This article shows you how to Open File Location from Visual C# 2008 code.
  • Drag the OpenFileDialog Control to Form
  • Add Reference {Microsoft.VisualBasic}
  • Sample images

  • Coding
    Microsoft.VisualBasic.Interaction.Shell("explorer.exe /select, "+
                       this.txtFileName.Text, 
                       Microsoft.VisualBasic.AppWinStyle.NormalFocus, true, 20);
    
Download Source Code Here
 

How to Export Data from DataGridView in C# to Microsoft Excel?

E-mail Print PDF
This article shows you C# code on export data from DataGridView to Microsoft Excel. In here, you will see how to set font to excel cell and how to make columns become autofit.
  • First, you need to add Microsoft.Office.Interop.Excel as a reference

  • Write C# code using Microsoft.Offce.Interop.Excel namespace

    Download Source Code Here
     
    Microsoft.Office.Interop.Excel.Application ExcelApp = 
              new Microsoft.Office.Interop.Excel.Application();
    Microsoft.Office.Interop.Excel._Workbook ExcelBook;
    Microsoft.Office.Interop.Excel._Worksheet ExcelSheet;
    
    int i = 0;
    int j = 0;
    
    //create object of excel
    ExcelBook = (Microsoft.Office.Interop.Excel._Workbook)ExcelApp.Workbooks.Add(1);
    ExcelSheet = (Microsoft.Office.Interop.Excel._Worksheet)ExcelBook.ActiveSheet;
    //export header
    for (i = 1; i <= this.dgvData.Columns.Count ; i++)
    {
        ExcelSheet.Cells[1, i] = this.dgvData.Columns[i - 1].HeaderText;
    }
    
    //export data
    for (i = 1; i <= this.dgvData.RowCount; i++)
    {
        for (j = 1; j <= dgvData.Columns.Count ; j++)
        {
            ExcelSheet.Cells[i + 1, j] = dgvData.Rows[i - 1].Cells[j - 1].Value;
        }
    }
    
    ExcelApp.Visible = true;
    
    //set font Khmer OS System to data range
    Microsoft.Office.Interop.Excel.Range myRange = ExcelSheet.get_Range(
                              ExcelSheet.Cells[1, 1],
                              ExcelSheet.Cells[this.dgvData.RowCount + 1, 
                              this.dgvData.Columns.Count]);
    Microsoft.Office.Interop.Excel.Font x = myRange.Font;
    x.Name = "Arial";
    x.Size = 10;
    
    //set bold font to column header
    myRange = ExcelSheet.get_Range(ExcelSheet.Cells[1, 1], 
                             ExcelSheet.Cells[1, this.dgvData.Columns.Count]);
    x = myRange.Font;
    x.Bold = true;
    //autofit all columns
    myRange.EntireColumn.AutoFit();
    
    //
    ExcelSheet = null;
    ExcelBook = null;
    ExcelApp = null;
    
 

How to insert Unicode Text from VB 2008 into Table in Microsoft SQL Server?

E-mail Print PDF
This article describes about how to insert Unicode data into SQL Server 2000.
  • Take not that fields to be stored Unicode data in SQL Server Table must be nvarchar, nchar, or ntext
  • Choose Latin1_General_BIN for Collation property of each Unicode field (see image below)

  • Assume that we have one SQL Server table as below:
    Student (stdid: int, lastname: nvarchar(50), firstname: nvarchar(50))
  • Write Visual Basic .Net 2008 Code as below:
    Dim cn As New OleDb.OleDbConnection
            cn.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI; " & _
                                    "Data Source=.; " & _
                                    " Persist Security Info=False; Initial Catalog=Test"
            cn.Open()
    
            Dim cmd As New OleDb.OleDbCommand
            cmd.Connection = cn
            cmd.CommandText = "INSERT INTO student(stdid, lastname, firstname) " & _
                            " VALUES(" & Me.txtID.Text & "," & _
                            "N'" & Me.txtLastName.Text & "'," & _
                            "N'" & Me.txtFirstName.Text & "')"
            cmd.ExecuteNonQuery()
    
            cn.Close()
 

How to Create Folder using Visual Basic .Net

E-mail Print PDF
Follow the below steps:
  • Create New Windows Form
  • Draw one Button on the above Windows Form
  • Write the below code in Button_Click Event
    Private Sub Button1_Click(ByVal sender As System.Object, _
                              ByVal e As System.EventArgs) Handles Button1.Click
        System.IO.Directory.CreateDirectory("C:\New Folder")
    End Sub
 


Page 10 of 19