|
Pseudocode for Binary Search Method in Sorting List (for VB2008) |
|
|
|
សរសេរដោយ Setha IECH
|
|
អង្គារ, 25 ឧសភា 2010 11:02 |
Declare search_value As String Declare n As Integer Input n Declare list(1 to n) As String Input search_value Declare i As Integer For i=0 to n-1 Increased by 1 Input list(i) End For Declare start_index As Integer Declare end_index As Integer Declare mid_index As Integer Declare found_index As Integer Set found_index = -1 Set start_index=1 Set end_index=n Do mid_index = (Round Down) (start_index+end_index)/2 If end_index<=start_index Then If search_value = list(mid_index) Then found_index = mid_index End If Exit Do Else If search_value = list(mid_index) Then found_index = mid_index Exit Do Else If search_value < list(mid_index) Then end_index = mid_index – 1 Else start_index = mid_index + 1 End If End If End Do Loop If found_index = -1 Then Display “Search not found!” End If Output found_index |
|
Pseudocode for N-Variable System Linear Equation (for VB2008) |
|
|
|
សរសេរដោយ Setha IECH
|
|
អាទិត្យ, 23 ឧសភា 2010 13:54 |
- Identify Output
x1, x2, x3, ………, xn - Determine Input
b1, b2, b3, ………, bn a11, a12, a13, ………., a1n a21, a22, a23, ………., a2n ……………… an1, an2, an3, ………., ann - Determine Process
Declare n as Integer Input value of n Declare a(1 to n,1 to n), b(1 to n), DetD, DetDx(1 to n), x(1 to n) As Double Declare temp(1 to n) As Double Declare i, j As Integer For i=1 to n increased by 1 For j=1 to n increased by 1 input value of a(i, j) End For input value of b(i) End for DetD = CalculateDet (n, a) For i=1 to n increased by 1 For j=1 to n increased by 1 temp (j) = a (j, i) a(j, i) = b(j) End For DetDx(i) = CalculateDet (n , a) If DetD=0 Then If DetDx(i)=0 then Display Message “Infinite root!” Else Display Message “No root!” End If Exit For End If
x(i) = DetDx(i)/DetD Display x(i)
For j=1 to n increased by 1 a(j, i) = temp (j) End for End of For Function CalculateDet - Function CalculateDet
Parameters pass in: n and a(1 to n, 1 to n) Declare Det As Integer If n = 2 Then Det = a(1, 1) * a(2, 2) – a(2, 1) * a(1, 2) Else Declare temp(1 to n-1, 1 to n-1) As Double Declare Coef, m, k, j, i As Integer Det = 0 For i = 1 to n increased by 1 For j=2 to n increased by 1 m = 1 For k=1 to n increased by 1 If k ! = i Then temp(m, j-1) = a(k, j) m = m + 1 End If End For End For
If i modulus 2 = 0 Then Coef = -1 Else Coef = 1 End If Det = Det + Coef * a(i, 1) * CalculateDet (n-1, temp) End For End If Return Value of Det End Function
|
|
Export Data from VB 2008 to Excel |
|
|
|
សរសេរដោយ Setha IECH
|
|
ពុធ, 19 ឧសភា 2010 08:41 |
|
Private Sub btnExcel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExcel.Click Dim ExcelApp As Object, ExcelBook As Object Dim ExcelSheet As Object Dim i As Integer Dim j As Integer 'create object of excel ExcelApp = CreateObject("Excel.Application") ExcelBook = ExcelApp.WorkBooks.Add ExcelSheet = ExcelBook.WorkSheets(1) With ExcelSheet For i = 1 To Me.DataGridView1.RowCount .cells(i, 1) = Me.DataGridView1.Rows(i - 1).Cells("id").Value For j = 1 To DataGridView1.Columns.Count - 1 .cells(i, j + 1) = DataGridView1.Rows(i - 1).Cells(j).Value Next Next End With ExcelApp.Visible = True 'set page margin ExcelSheet.PageSetup.PaperSize = 9 ExcelSheet.PageSetup.LeftMargin = ExcelApp.InchesToPoints(0.3) ExcelSheet.PageSetup.RightMargin = ExcelApp.InchesToPoints(0.3) ExcelSheet.PageSetup.TopMargin = ExcelApp.InchesToPoints(0.3) ExcelSheet.PageSetup.BottomMargin = ExcelApp.InchesToPoints(0.3) ExcelSheet.PageSetup.CenterHorizontally = True ' ExcelSheet = Nothing ExcelBook = Nothing ExcelApp = Nothing
End Sub Download Source Code Here |
|
VB.Net 2008 OleDb Connect to MS-Access with Password (Visual Basic 2008) |
|
|
|
សរសេរដោយ Setha IECH
|
|
អង្គារ, 11 ឧសភា 2010 10:24 |
|
Dim con As New OleDb.OleDbConnection con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & _ Application.StartupPath & "\dbstudent.mdb;" & _ "Jet OLEDB:Database Password=12345" con.Open() '---------------------- Dim da As New OleDb.OleDbDataAdapter("SELECT * FROM tblstudent", con) '---------- con.Close() con.Dispose() |
|
|