• Increase font size
  • Default font size
  • Decrease font size
Visual Basic / VBA

How to Convert Khmer Unicode Data to Unicode Code in Visual Basic?

E-mail Print PDF
This article shows you Visual Basic code on how to convert Khmer Unicode Data into Unicode Code.
Function UnicodeString(ByVal str As String) As String
    Dim reVal As String
    Dim i As Integer
    For i = 1 To Len(str)
        reVal = reVal & AscW(Mid(str, i, 1))
    UnicodeString = reVal
End Function

Why we need this?

We need to convert Unicode Data to Unicode Code in Microsoft Access Table in order to enable sorting and searching of Khmer Unicode Data. As experiences with Khmer Unicode, we cannot sort or search in field which consist of Khmer Unicode data. Therefore, we need to convert those Khmer Unicode Data into Unicode Code and add to another new column which we can sort and search instead.


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 change screen resolution using Visual Basic 6?

E-mail Print PDF

This sample show you how to write Visual Basic 6 (VB6) code to change screen resolution (example: change screen resolution to 1024x768). You will see the uses of API function as follow:

Public Declare Function GetSystemMetrics Lib "user32.dll" .................
Public Declare Function EnumDisplaySettings Lib "user32.dll" ................
Public Declare Function ChangeDisplaySettings Lib "user32.dll" ............
Public Declare Function ExitWindowsEx Lib "user32.dll" .........

Download Sample Here

How to Save Image into MS-Access 2003 from Visual Basic 6?

E-mail Print PDF
This article is a sample of saving image from Visual Basic 6 into Microsoft Access Database.
  • Create New Project in VB6: Project1
  • Create New Form: Form1
  • Draw Controls on Form as following:
    • One TextBox Control
    • One Image Control
    • Two Command Controls for Save and Close
    • Two Command Controls for Browse and Remove Image
    • One Command Control to Get data back from Database with the text enter TextBox Control
  • Add Component: Microsoft Command Dialog Control 6.0
  • See Image below
  • Add Reference: Microsoft ActiveX Data Objects 2.1 Library (Project->References)
  • Create Database in Microsoft Access (data.mdb) with the following table:
    • Table name: student
    • Fields
      FieldData Type
      photoOLE Object
  • Coding (Download sample below)

Download Sample Code Here

How to Import Data from Excel into ListView in Visual Basic 6

E-mail Print PDF

Assume that we have an Excel file named Book3.xls locates in the same folder as the project folder which consists of data in four columns of the first sheet. We will import those data in Excel file into the ListView (have the same four columns as in Excel) in Visual Basic 6.

    Dim ExcelObj As Object
    Dim ExcelBook As Object
    Dim ExcelSheet As Object
    Dim i As Integer

    Set ExcelObj = CreateObject("Excel.Application")
    Set ExcelSheet = CreateObject("Excel.Sheet")
    ExcelObj.WorkBooks.Open App.Path & "\Book3.xls"
    Set ExcelBook = ExcelObj.WorkBooks(1)
    Set ExcelSheet = ExcelBook.WorkSheets(1)
    Dim l As ListItem
    With ExcelSheet
    i = 1
    Do Until .cells(i, 1) & "" = ""
        Set l = lvwList.ListItems.Add(, , .cells(i, 1))
        l.SubItems(1) = .cells(i, 2)
        l.SubItems(2) = .cells(i, 3)
        l.SubItems(3) = .cells(i, 4)
        i = i + 1

    End With
    Set ExcelSheet = Nothing
    Set ExcelBook = Nothing
    Set ExcelObj = Nothing

Download Sample Code

Page 2 of 4