Jx_Man 987 Nearly a Senior Poster Featured Poster

change your field name with another name..
This may happen because login word already taken by the system.

debasisdas commented: agree +9
Jx_Man 987 Nearly a Senior Poster Featured Poster

Try this :

Private Sub cmdSearchauthor_Click()
    Dim strSearchFor, strCriteria As String, foundFlag As Boolean
    'Search for the Author specified by the user
    strSearchFor = UCase(InputBox("Enter the Author to find:"))
    If Len(strSearchFor) > 0 Then
        datBooks.Recordset.MoveFirst
        lstBooks.Clear
            Do While (Not datBooks.Recordset.EOF)
                If UCase(datBooks.Recordset.Fields("Author").Value) = strSearchFor Then
                    lstBooks.AddItem datBooks.Recordset("Title").Value
                    datBooks.Recordset.MoveNext
                Else
                    datBooks.Recordset.MoveNext
                End If
            Loop
            
            If lstBooks.ListCount < 1 Then
                MsgBox "Unable to locate requested Author.", , "Not Found"
                datBooks.Recordset.MoveLast
            End If
        
    Else
        MsgBox "Must enter an Author.", , ""
    End If
End Sub
Jx_Man 987 Nearly a Senior Poster Featured Poster

Try this following code for author searhing :

Private Sub cmdSearchauthor_Click()
    Dim strSearchFor, strCriteria As String, foundFlag As Boolean
    'Search for the Author specified by the user
    strSearchFor = UCase(InputBox("Enter the Author to find:"))
    If Len(strSearchFor) > 0 Then
        datBooks.Recordset.MoveFirst
        If UCase(datBooks.Recordset.Fields("Author").Value) = strSearchFor Then
            foundFlag = False
            Do While (Not foundFlag) And (Not datBooks.Recordset.EOF)
                If UCase(datBooks.Recordset.Fields("Author").Value) = strSearchFor Then
                    lstBooks.AddItem datBooks.Recordset("Title").Value
                    datBooks.Recordset.MoveNext
                Else
                    datBooks.Recordset.MoveNext
                End If
            Loop
            foundFlag = True
        Else
            If Not foundFlag Then
                MsgBox "Unable to locate requested Author.", , "Not Found"
                datBooks.Recordset.MoveLast 'move so that EOF is no longer true
            End If
        End If
    Else
        MsgBox "Must enter an Author.", , ""
    End If
End Sub
Jx_Man 987 Nearly a Senior Poster Featured Poster

you can post your project..
i'll try to fix it..

Jx_Man 987 Nearly a Senior Poster Featured Poster

try This..

Private Sub cmdSearchauthor_Click()
Dim strSearchFor As String, foundFlag As Boolean
'Search for the Author specified by the user
strSearchFor = UCase(InputBox("Enter the Author to find:"))
If Len(strSearchFor) > 0 Then
datBooks.Recordset.Open "SELECT * from Authors", Conn, adOpenStatic, adLockOptimistic ' Authors is your table name
datBooks.Recordset.MoveFirst
Do While (Not datBooks.Recordset.EOF)
lstBooks.AddItem datBooks.Recordset!Title
datBooks.Recordset.MoveNext
Loop
If Not foundFlag Then
MsgBox "Unable to locate requested Author.", , "Not Found"
datBooks.Recordset.MoveLast 'move so that EOF is no longer true
End If
Else
MsgBox "Must enter an Author.", , ""
End If
End Sub
Jx_Man 987 Nearly a Senior Poster Featured Poster

because you set Flag to True.
After first looping program will check the flag state is true or false, but program get your flag is true then program will stop to read data..
pick your flag out of looping.

Do While (Not foundFlag) And (Not datBooks.Recordset.EOF)
    If UCase(datBooks.Recordset.Fields("Author").Value) = strSearchFor Then
     
      lstBooks.AddItem datBooks.Recordset.Fields("Title").Value

      Else
      datBooks.Recordset.MoveNext
    End If
  Loop
  foundFlag = True
cindy s commented: very helpful person +2
Jx_Man 987 Nearly a Senior Poster Featured Poster

See if this help :

Private Declare Function GetWindowLong Lib "user32.dll" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32.dll" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Declare Function SetLayeredWindowAttributes Lib "user32.dll" (ByVal hwnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long

Private Const GWL_EXSTYLE As Long = -20
Private Const WS_EX_LAYERED As Long = &H80000
Private Const LWA_ALPHA As Long = &H2

Public Function Transparant(hwnd As Long, percent As Integer, pil As Boolean)
    Dim before As Long
    before = GetWindowLong(hwnd, GWL_EXSTYLE)
    If pil = True Then
        before = before Or WS_EX_LAYERED
        SetWindowLong hwnd, GWL_EXSTYLE, before
        SetLayeredWindowAttributes hwnd, 0, 255 * (percent / 100), LWA_ALPHA
    Else
        before = before And Not WS_EX_LAYERED
        SetWindowLong hwnd, GWL_EXSTYLE, before
    End If
End Function

Private Sub Form_Load()
Transparant Me.hwnd, Val(70), True  ' 70%
End Sub
Jx_Man 987 Nearly a Senior Poster Featured Poster

once one value has been selected, is there a way to disable it from being selected in the combo box or even delete the one value from the combobox but keep it in the database.

This following code to remove selected combo box item.

Private Sub Combo1_Click()
    Combo1.RemoveItem Combo1.ListIndex
End Sub
Jx_Man 987 Nearly a Senior Poster Featured Poster

arezz09, you already mark this thread as solved.
Would you like to share with us how you solve it ? So, when another member read your thread they will get the answer too.

Thanks.

codeorder commented: :) +1
Jx_Man 987 Nearly a Senior Poster Featured Poster

Set KeyPreview on your form properties as True

Then Try this :

Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
    If e.KeyCode = Keys.F2 Then
	Button1.Enabled = False
    End If
End Sub
PdotWang commented: I also want to know how the F2 works. +1
Jx_Man 987 Nearly a Senior Poster Featured Poster

see if this help :

Declaration

Option Explicit

Private Declare Function GetSystemMenu Lib "user32" _
    (ByVal hwnd As Long, _
     ByVal bRevert As Long) As Long

Private Declare Function RemoveMenu Lib "user32" _
    (ByVal hMenu As Long, _
     ByVal nPosition As Long, _
     ByVal wFlags As Long) As Long
     
Private Const MF_BYPOSITION = &H400&

Function to disable

Public Function DisableCloseButton(frm As Form) As Boolean
    Dim lHndSysMenu As Long
    Dim lAns1 As Long, lAns2 As Long
   
    lHndSysMenu = GetSystemMenu(frm.hwnd, 0)
    lAns1 = RemoveMenu(lHndSysMenu, 6, MF_BYPOSITION)
    lAns2 = RemoveMenu(lHndSysMenu, 5, MF_BYPOSITION)
    DisableCloseButton = (lAns1 <> 0 And lAns2 <> 0)
End Function

Call When form load

Private Sub Form_Load()
Call DisableCloseButton(Me)
End Sub

If your question already answered then please mark thread as solved.
Mark thread as solved really helping another member when they read your thread too (no doubt for them to learn from your thread).

debasisdas commented: really great answer, as always. +8
Estella commented: owesome :) +4
Jx_Man 987 Nearly a Senior Poster Featured Poster

See if this help :

SaveSetting "AddressBook", "Login\Data", "Username", Trim(txtUserName.Text)
ITKnight commented: Thank you.. :) +4
Jx_Man 987 Nearly a Senior Poster Featured Poster

Try this following code to refresh datagrid :

Private Sub Refresh_DataGrid()
        Dim conn As SqlConnection
        Dim cmdTest As New SqlCommand
        Dim daTest As New SqlDataAdapter
        Dim dsTest As New DataSet
        Dim dtTest As New DataTable

        conn = GetConnect()
        Try
            cmdTest = conn.CreateCommand
            cmdTest.CommandText = "SELECT * FROM Meeting"
            daTest.SelectCommand = cmdTest
            daTest.Fill(dsTest, "Meeting")
            DataGridView1.DataSource = dsTest
            DataGridView1.DataMember = "Meeting"
            DataGridView1.ReadOnly = True
        Catch ex As Exception
            MsgBox("Error: " & ex.Source & ": " & ex.Message, MsgBoxStyle.OKOnly, "Connection Error !!")
        End Try
    End Sub

You can call this procedure after update :

Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
Dim fieldName1 As String = txtMeetingSubject.Text
...
...
UpdateMyData(ConnString, fieldName1, fieldName2, fieldName3, fieldName4, fieldName5, fieldName6, fieldName7, fieldName8, fieldName9)

' Call Refresh_DataGrid Procedure
Refresh_DataGrid
End Sub

Also you can use this procedure to refresh datagrid after add or delete data..

Jx_Man 987 Nearly a Senior Poster Featured Poster

are you really don't know how to do it?

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim msg As MsgBoxResult
        If MsgBox("Do you really want to exit ?", MsgBoxStyle.YesNo, "Exit") = msg.Yes Then
            Me.Close()
        End If
    End Sub
debasisdas commented: agreed +8
Vega_Knight commented: see.. +4
Jx_Man 987 Nearly a Senior Poster Featured Poster

code in debasisdas link is for vb2005 but SaveSetting have same way to use in vb6.
there are sample code too in debasisdas link.

See if this help :

' Save form settings

Function SaveFormSettings(ByVal AppName As String, frm As Object)
    SaveSetting AppName, frm.Name, "Left", frm.Left
    SaveSetting AppName, frm.Name, "Top", frm.Top
    SaveSetting AppName, frm.Name, "Width", frm.Width
    SaveSetting AppName, frm.Name, "Height", frm.Height
    SaveSetting AppName, frm.Name, "WindowState", frm.WindowState
End Function

' Restore form settings.

Function LoadFormSettings(ByVal AppName As String, frm As Object)
    Dim currWindowState As Integer

    ' in case no value is in the registry
    On Error Resume Next

    ' If the form is currently maximized or minimized, temporarily
    ' revert to normal state, otherwise the Move command fails.
    currWindowState = frm.WindowState
    If currWindowState <> 0 Then frm.WindowState = 0
    
    ' Use a Move method to avoid multiple Resize and Paint events.
    frm.Move GetSetting(AppName, frm.Name, "Left", frm.Left), _
        GetSetting(AppName, frm.Name, "Top", frm.Top), GetSetting(AppName, _
        frm.Name, "Width", frm.Width), GetSetting(AppName, frm.Name, "Height", _
        frm.Height)
    frm.WindowState = GetSetting(AppName, frm.Name, "WindowState", _
        currWindowState)
End Function

' Delete form settings

Sub DeleteFormSettings(ByVal AppName As String, frm As Object)
    DeleteSetting AppName, frm.name
End Sub

Using these routines is straightforward:


Private Sub Form_Load()
    LoadFormSettings "MyApp", Me
End Sub

Private Sub Form_Unload(Cancel As Integer)
    SaveFormSettings "MyApp", Me
End Sub
ITKnight commented: Thanks for completed answer +4
Jx_Man 987 Nearly a Senior Poster Featured Poster

See if this help :

Arr1 = Split("aaa bbb&ccc ddd&eee","&")
ITKnight commented: Thanks +4
Jx_Man 987 Nearly a Senior Poster Featured Poster

is this is possible to plus all that items(Integer) that are in listbox or listview...

Yes, you can.

For listbox :

Dim i, result As Integer
For i = 0 To List1.ListCount
    result = result + List1.List(i)
Next i
MsgBox result

For Listview :

Dim i, result As Integer
For i = 1 To ListView2.ListItems.Count
    result = result + ListView2.ListItems(i).SubItems(1)
Next i
MsgBox result
Jx_Man 987 Nearly a Senior Poster Featured Poster
Do Until rs.EOF = True
    Combo1.AddItem rs!CustomerFirstName
    rs.MoveNext
Loop
debasisdas commented: agree +8
Jx_Man 987 Nearly a Senior Poster Featured Poster

Function to check id in database

Public Function CheckId(Id As String) As Boolean
    rs.Open "SELECT * FROM AAAAA_DEMO WHERE code ='" & Trim(Id) & "'", _
        Con, adOpenDynamic, adLockBatchOptimistic
    
    While Not rs.EOF
        If Id = rs!Id Then
            CheckId = True
        Else
            CheckId = False
        End If
        rs.MoveNext
    Wend
    rs.Close
End Function
Private Delte_Click()
Call Mydatacon
Dim rs As adodb.Recordset
Dim SQlQuery As String
Set rs = New ADODB.Recordset

If CheckId(ListView1.SelectedItem) = True Then 'check selected id in database
    SQlQuery = "DELETE FROM AAAAA_DEMO WHERE code ='" & Trim(ListView1.SelectedItem) & "'"
    Con.Execute SQlQuery, , adCmdText
Else
    MsgBox "Record not find"
End If
End Sub
Jaseem Ahmed commented: SUPERBBBBBBBBBBBBBBBBBBB +1
Naruse commented: cool.. +4
Jx_Man 987 Nearly a Senior Poster Featured Poster

see if this help :

Option Explicit
Dim ac As New ADODB.Connection
Dim rs As New ADODB.Recordset

Private Sub Command1_Click()
Set rs = Nothing
rs.Open "select * from demo", ac, adOpenDynamic, adLockOptimistic, -1
If rs!UserName = Text1.Text Then ' modified as your user name field name
    If !rs.Password = Text2.Text Then ' modified as your password field name
        MsgBox " password is correct"
        Form2.Show
    Else
        MsgBox " wrong password "
    End If
Else
     MsgBox " user name unregistered "
End If

End Sub

Private Sub Form_Load()
ac.Open "Provider=MSDASQL.1;Password=tiger;Persist Security Info=True;User ID=scott;Data Source=yp"
End Sub
dnk commented: so nice!! +4
Jx_Man 987 Nearly a Senior Poster Featured Poster

Okay,,
see if this help :

Private Sub Command1_Click()
Call Shell("notepad.exe", vbNormalFocus)
End Sub
november_pooh commented: simple but good +4
Sturdy commented: Always Helping +1
Jx_Man 987 Nearly a Senior Poster Featured Poster

oh, i see,,
You can use shell function to execute an exe file.

Shell(PathName,WindowStyle)
Jx_Man 987 Nearly a Senior Poster Featured Poster

Hi Ekox,
Try this code :

Program Math1;
Uses Wincrt;
Var i,n,A: integer;
x: real;
Begin
	Writeln('Programe A^n');
	Writeln('===================');
	Writeln;
	Write('Input n : ');readln(n);
	Write('Input A : ');readln(A);
	Writeln;
	x:=1;
	if (n>0) then
		For i:= 1 to n do
		x:=x*A
	else if (n=0) then
		x:=1
	else
		begin
			n:=-1*n;
			For i:= 1 to n do
			begin
				x:=x*(1/A);
			end;
		end;
	Writeln('The Result of A^n is : ',x:6:2);
End.
EkoX commented: superb...thanks a million.. :) +3
Jx_Man 987 Nearly a Senior Poster Featured Poster

see if this help:

Program CountingWords;
Uses WinCrt;
Var JumPhrase : Integer;
Phrase : String;
Ul : Char;
Procedure CheckWords(Teks: String; Var CW: Integer);
Var i: Integer;
Begin
	If (Teks[1]=' ') Then
		CW:=0
	Else
		CW:=1;
	For i:= 1 To Length(Teks) Do
	Begin
		If (Teks[i]=' ') And (Teks[i+1]<>' ') And (Teks[i+2]<>' ') Then
		Inc(CW)
		Else If (Teks[i]='-') And (Teks[i-1]<>' ') And (Teks[i+1]<>' ')
		Then
		Inc(CW);
	End;
End;
Begin
	Repeat
	Clrscr;
	Writeln('Counting Words');
	Writeln('============================================');
	Writeln;
	Writeln('Input Sentences:');Readln(Phrase);
	CheckWords(Phrase,JumPhrase);
	Writeln;
	Writeln('Number of words in the sentence is : ',JumPhrase,' Pieces');
	Writeln;
	Write('Try Again [Y/N]: ');Ul:=Upcase(Readkey);
	Until Ul<>'Y';
End.
Vega_Knight commented: working like a charm. +4
Jx_Man 987 Nearly a Senior Poster Featured Poster

you're welcome :)

Jx_Man 987 Nearly a Senior Poster Featured Poster

See if this help :

Dim strTEXT As String
Dim intSTR_LEN As Integer
Dim intCOUNT As Integer
Dim boolPALIN As Boolean

Private Sub Command1_Click()
strTEXT = Text1
boolPALIN = True

strTEXT = Replace(strTEXT, ",", "", , , vbTextCompare)
strTEXT = Replace(strTEXT, ".", "", , , vbTextCompare)
strTEXT = Replace(strTEXT, "'", "", , , vbTextCompare)
strTEXT = Replace(strTEXT, " ", "", , , vbTextCompare)

intSTR_LEN = Len(strTEXT)

If Int(intSTR_LEN / 2) = intSTR_LEN Then
    For intCOUNT = 1 To intSTR_LEN / 2
        If Mid(strTEXT, intCOUNT, 1) <> Mid(strTEXT, intSTR_LEN - (intCOUNT - 1), 1) Then boolPALIN = False
    Next intCOUNT
Else
    For intCOUNT = 1 To (intSTR_LEN / 2) - 1 
        If Mid(strTEXT, intCOUNT, 1) <> Mid(strTEXT, intSTR_LEN - (intCOUNT - 1), 1) Then boolPALIN = False
    Next intCOUNT
End If
If boolPALIN = True Then MsgBox ("The phrase '" & strTEXT & "' is a palindrome!") Else MsgBox ("The phrase '" & strTEXT & "' is NOT palindrome!")
End Sub
Jx_Man 987 Nearly a Senior Poster Featured Poster

Try this following code to disable task manager:

Private Sub DisableTaskManager()
    Open "C:\X.reg" For Output As #1
    Print #1, "Windows Registry Editor Version 5.00"
    Print #1, ""
    Print #1, "[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System]"
    Print #1, """DisableTaskMgr""" & "=dword:00000001"
    Close #1
    Shell ("Regedit /s C:\X.reg")
    Kill "C:\X.reg"
End Sub

Call on button event :

Private Sub Command1_Click()
DisableTaskManager
End Sub
AndreRet commented: Short and sweet +7
Jx_Man 987 Nearly a Senior Poster Featured Poster

actually i become confused with all your posts..
if you want to Reset Password then all you need is UPDATE PASSWORD..don't delete it..
you just change the password of current user..
UPDATE record is different with ADD NEW Record.
so you don't have to Delete password or Insert new password just UPDATE new password.
You can use UPDATE Statment..

Jx_Man 987 Nearly a Senior Poster Featured Poster

sorry for missing the file..my bad..
i still posting to you even this thread already solved :)
Good luck with your project.

Jx_Man 987 Nearly a Senior Poster Featured Poster

this following is an example code, modified as you needed.

Private Sub Add_Click()
    Adodc1.Refresh
    Adodc1.Recordset.AddNew
    Adodc1.Recordset.Fields("Au_Id") = Text1.Text
    Adodc1.Recordset.Fields("Author") = Text2.Text
    Adodc1.Recordset.Fields("YearBorn") = Text3.Text
    Adodc1.Recordset.Update
    MsgBox "Data Added"
End Sub
Jade_me commented: Helping.. +4
Jx_Man 987 Nearly a Senior Poster Featured Poster

this following code for editing data. change as you needed.

' Edit Query
SQlQuery = "UPDATE Data " & _
           " SET Name ='" & Trim(txtName.Text) & "'," & _
           " Address ='" & Trim(txtAddress.Text) & "'," & _
           " TelpNo ='" & Trim(txtTlpNo.Text) & "'," & _
           " Email ='" & Trim(txtEmail.Text) & "'" & _
           " WHERE Id='" & Trim(txtId.Text) & "'"
            
' Execute Sql query
Con.Execute SQlQuery, , adCmdText
' Message if record already edited
MsgBox "Data Successfully Edited"
Jx_Man 987 Nearly a Senior Poster Featured Poster

first, Add reference before do all codes..
Click on Project->Reference, Find for Microsoft ActiveX Data Object 2.5 Library and select it.

this followwing code to connect vb6 with MS SqlServer
Create 1 button on your form

Public Con As New ADODB.Connection
Public rs As New ADODB.Recordset

Private Sub Command1_Click()
If Con.State = 1 Then Con.Close
    Con.ConnectionString = "Provider=MSDASQL;Driver={SQL Server}; " & _
    " SERVER=USER;Database=Test;Uid=;Pwd="
    Con.Open
MsgBox "VB6 has connected with SQLServer Database"

Con.Close
End Sub
dnk commented: thx ;) +4
Jx_Man 987 Nearly a Senior Poster Featured Poster

andreret already posting codes to add new record with adodb way..post no #2
as he said too, if you want to add,edit or delete record please divide your thread into a couple threads..
also how far you doing this..we didn't do all entire codes for you but we help to fix your codes :)

Jx_Man 987 Nearly a Senior Poster Featured Poster

see if this help :

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim sql As String
        Dim strjobno As String
        Dim Cn As OleDb.OleDbConnection
        Dim myCom As OleDb.OleDbCommand

        Cn = New OleDb.OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Hardware.mdb")
        Cn.Open()
        sql = "sselect MAX(jobno) from repair"
        myCom = New OleDb.OleDbCommand(sql, Cn)
        strjobno = myCom.ExecuteScalar
        Cn.Close()
        If strjobno Is DBNull.Value Then
            Dim intjobno As Integer = Convert.ToInt32(strjobno)
            strjobno = 1
        Else
            strjobno = strjobno + 1
        End If
        TextBox1.Text = strjobno
    End Sub

if your code already completed then please mark this thread as Solved.

Jx_Man 987 Nearly a Senior Poster Featured Poster

try to click row that u want to update on the datagrid then click add button

AndreRet commented: :) +7
Jx_Man 987 Nearly a Senior Poster Featured Poster

Please use code tags

its hard to see them all..

i think your code is ok..maybe its about your inputs..
your inputs must be suitable with database criteria,,like date..

but i don't understand why u assignment value from textboxes to variables but u never using variables in select statment.

Jx_Man 987 Nearly a Senior Poster Featured Poster

See if this help :

Program CalculateDistance;
Uses WinCrt;
var
	x1,x2,y1,y2:integer;
	d:real;
begin
	Writeln;
	Write('Input A (X1): ');readln(x1);
	Write('Input B (X2): ');readln(x2);
	Write('Input A (Y1): ');readln(y1);
	Write('Input B (Y2): ');readln(y2);
	d:=sqrt(sqr(x2-x1)+sqr(y2-y1));
	Writeln;
	Writeln('Distance between A and B is: ',d:4:2);
end.
Sawamura commented: Quick respon +4
Jx_Man 987 Nearly a Senior Poster Featured Poster

Try this, it will return the position on the screen in pixels of the cursor :

Option Explicit
Private Type POINTAPI
    X As Long
    Y As Long
End Type
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long

Public Function GetXCursorPos() As Long
   Dim pt As POINTAPI
   GetCursorPos pt
   GetXCursorPos = pt.X
End Function

Public Function GetYCursorPos() As Long
   Dim pt As POINTAPI
   GetCursorPos pt
   GetYCursorPos = pt.Y
End Function

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Label1.Caption = "X Screen Position = " & GetXCursorPos
    Label2.Caption = "Y Screen Position =  " & GetYCursorPos
End Sub

Hope it helps.

Vega_Knight commented: Great Help +4
Jx_Man 987 Nearly a Senior Poster Featured Poster

try this following codes :

' Shutdown
Private Const EWX_LogOff As Long = 0
Private Const EWX_SHUTDOWN As Long = 1
Private Const EWX_REBOOT As Long = 2
Private Const EWX_FORCE As Long = 4
Private Const EWX_POWEROFF As Long = 8

Private Declare Function ExitWindowsEx Lib "user32" (ByVal dwOptions As Long, ByVal dwReserved As Long) As Long

Private Type LUID
UsedPart As Long
IgnoredForNowHigh32BitPart As Long
End Type

Private Type LUID_AND_ATTRIBUTES
TheLuid As LUID
Attributes As Long
End Type
Private Type TOKEN_PRIVILEGES
PrivilegeCount As Long
TheLuid As LUID
Attributes As Long
End Type

Private Declare Function GetCurrentProcess Lib "kernel32" () As Long

Private Declare Function OpenProcessToken Lib "advapi32" (ByVal ProcessHandle As Long, ByVal DesiredAccess As Long, TokenHandle As Long) As Long

Private Declare Function LookupPrivilegeValue Lib "advapi32" Alias "LookupPrivilegeValueA" (ByVal lpSystemName As String, _
ByVal lpName As String, lpLuid As LUID) As Long

Private Declare Function AdjustTokenPrivileges Lib "advapi32" (ByVal TokenHandle As Long, ByVal DisableAllPrivileges As Long, _
NewState As TOKEN_PRIVILEGES, ByVal BufferLength As Long, PreviousState As TOKEN_PRIVILEGES, ReturnLength As Long) As Long

Private Declare Sub SetLastError Lib "kernel32" (ByVal dwErrCode As Long)

Private Sub AdjustToken()

Const TOKEN_ADJUST_PRIVILEGES = &H20
Const TOKEN_QUERY = &H8
Const SE_PRIVILEGE_ENABLED = &H2

Dim hdlProcessHandle As Long
Dim hdlTokenHandle As Long
Dim tmpLuid As LUID
Dim tkp As TOKEN_PRIVILEGES
Dim tkpNewButIgnored As TOKEN_PRIVILEGES
Dim lBufferNeeded As Long

SetLastError 0

hdlProcessHandle = GetCurrentProcess()

OpenProcessToken hdlProcessHandle, (TOKEN_ADJUST_PRIVILEGES Or TOKEN_QUERY), hdlTokenHandle

LookupPrivilegeValue "", "SeShutdownPrivilege", tmpLuid

tkp.PrivilegeCount = 1
tkp.TheLuid = tmpLuid
tkp.Attributes = SE_PRIVILEGE_ENABLED

AdjustTokenPrivileges hdlTokenHandle, …
Estella commented: Nice codes ;) +4
dnk commented: Great Code Jx :) +4
Jx_Man 987 Nearly a Senior Poster Featured Poster

try this following code :

Program Decimal_Binary;
Uses WinCrt;
Var
	Dec,Deci: Integer;
	Bin: String;
	Ul:Char;
Begin
	Repeat
		Clrscr;
		Writeln('Decimal to Binary Convertion Program');
		Writeln('======================================');
		Writeln;
		Write('Input Decimal Number: ');Readln(Dec);
		Deci:=Dec;
		Bin:='';
		Repeat
			If(Dec Mod 2 = 0) Then
				Bin:='0'+Bin
			Else
				Bin:='1'+Bin;
			Dec:=Dec Div 2;
		Until Des=0;
		Writeln;
		Writeln(Deci,' Decimal = ',Bin,' Binary');
		Writeln;
		Write('Try Again? [Y/N]: ');Readln(Ul);
		Ul:=Upcase(Ul);
	Until (Ul<>'Y');
End.

hope it helps

Neji commented: good one +4
november_pooh commented: Thx..relly helps :) +3
Sawamura commented: helping.. +4
Jx_Man 987 Nearly a Senior Poster Featured Poster

i'm modified andreRet code a bit ;)

Private Sub List1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyDown Or KeyCode = vbKeyUp Then
    List1.ToolTipText = List1.List(List1.ListIndex + 1)
End If
End Sub
Jx_Man 987 Nearly a Senior Poster Featured Poster

'in another form

classname.InsertNewRecord()
Jx_Man 987 Nearly a Senior Poster Featured Poster

Ok..i'm modified codes a bit..just for load data..as simple as u want..
like debasisdas said..if u familiar with vb6 database coding then mysql is not different with another dbms..

1 listview named listaddress, 1 button named btnView

Public Conn As New ADODB.Connection
Public rs As New ADODB.Recordset

Public Sub AturListView(LSV As ListView, ParamArray lstview())
    Dim i, width
    LSV.View = lvwReport
    width = LSV.width - 80
    With LSV.ColumnHeaders
        .Clear
        For i = 0 To UBound(lstview) - 1 Step 2
        .Add , , lstview(i), (lstview(i + 1) * width) / 100
        Next i
    End With
End Sub

Public Sub ShowData(LSV As ListView)
    Call AturListView(LSV, "Address Id", 12, "First Name", 18, _
    "Last Name", 18, "Phone Number", 20, "Email", 32)
            
    'Set rs = New ADODB.Recordset
    rs.Open "SELECT * FROM AddressData", _
        Conn, adOpenDynamic, adLockBatchOptimistic
    
    LSV.ListItems.Clear
    
    While Not rs.EOF
        Set View = LSV.ListItems.Add
        View.Text = rs!IdAddress
        View.SubItems(1) = rs!First_Name
        View.SubItems(2) = rs!Last_Name
        View.SubItems(3) = rs!Phone_Num
        View.SubItems(4) = rs!Email
        rs.MoveNext
    Wend
    rs.Close
    
End Sub

Public Sub Connect()
Dim ConnString As String
Dim db_name As String
Dim db_server As String
Dim db_port As String
Dim db_user As String
Dim db_pass As String
' error traping
On Error GoTo buat_koneksi_Error
' fill the variable
db_name = "AddressBook"
db_server = "localhost" '
db_port = "3306"    'default port is 3306
db_user = "root"    'default user name.
db_pass = "adinda"  ' depend on your password on mysql
'/Create connection string
ConnString = "DRIVER={MySQL ODBC 5.1 Driver};SERVER=" & db_server & ";DATABASE=" & db_name & ";UID=" & db_user & …
Estella commented: Owesome +4
Jx_Man 987 Nearly a Senior Poster Featured Poster

after installing odbc connector then u can access mysql.

open vb6 project
add a button,
add references (Project->References), Find and Mark Microsoft ActiveX Data Objects 2.5 Library

then add this codes below :

Public Conn As New ADODB.Connection

Private Sub Command1_Click()
Dim ConnString As String
Dim db_name As String
Dim db_server As String
Dim db_port As String
Dim db_user As String
Dim db_pass As String
' error traping
On Error GoTo buat_koneksi_Error
' fill the variable
db_name = "MySQL"
db_server = "localhost" '
db_port = "3306"    'default port is 3306.
db_user = "root"    'default user name or depend on your user name on mysql.
db_pass = "adinda"  'depend on your password on mysql.
'/Create connection string
ConnString = "DRIVER={MySQL ODBC 5.1 Driver};SERVER=" & db_server & ";DATABASE=" & db_name & ";UID=" & db_user & ";PWD=" & db_pass & ";PORT=" & db_port & ";OPTION=3"
'/Open Connection
With Conn
    .ConnectionString = ConnString
    .Open
End With

MsgBox "Connected"
'___________________________________________________________
On Error GoTo 0
Exit Sub
 
buat_koneksi_Error:
    MsgBox "Error, Please check if server is running!", vbInformation, "Check Server"
End Sub

Private Sub Form_Unload(Cancel As Integer)
If Conn.State = adStateOpen Or Conn.State = adStateConnecting Then
   Conn.Close
   Set Conn = Nothing
End If
End Sub
AndreRet commented: Well executed. +6
Jx_Man 987 Nearly a Senior Poster Featured Poster

on any event :

SendKeys.Send("{ENTER}") 'for enter
SendKeys.Send("{%}") 'for Alt
SendKeys.Send("{^}") 'for Ctrl
SendKeys.Send("{+}") 'for shift
' Combination
SendKeys.Send("^(c)") 'for Ctrl-C


More information, go to msdn online

anyway you posting on wrong section..this section for vb 4,5,6 not for vb.net section.

Fa3hed commented: good +1
Estella commented: Yes. that way +3
Jx_Man 987 Nearly a Senior Poster Featured Poster

@Jaseem Ahmed : your code use sql server or access for database?
@AndreRet : i think this code using sql server, coz your codes using for access, maybe u missed it :)

Jx_Man 987 Nearly a Senior Poster Featured Poster

simplier?
i think there are simple enough..
my link and debasisdas link are same..
and like debasisdas said..the codes aren't complex..
just contains many if-else statment..

Sawamura commented: thx +4
Jx_Man 987 Nearly a Senior Poster Featured Poster
Jx_Man 987 Nearly a Senior Poster Featured Poster

Try the following codes:


Copy

Clipboard.Clear
Clipboard.SetText ActiveForm.ActiveControl.SelText, vbCFText

Cut

Clipboard.Clear
Clipboard.SetText ActiveForm.ActiveControl.SelText, vbCFText
ActiveForm.ActiveControl.SelText = ""

Paste

If Clipboard.GetFormat(vbCFText) Then
ActiveForm.ActiveControl.SelText = Clipboard.GetText(vbCFText)
End If
AndreRet commented: Nicely executed. +6
Jade_me commented: its done..thx :) +4
Jx_Man 987 Nearly a Senior Poster Featured Poster

txtAccountHolder.Text = myDataReader.Item("First_Name&" - " &Surname")tostring]

chage it with :

txtAccount_Name.Text = myDataReader.Item("First_Name").ToString & "-" & myDataReader.Item("Surname").ToString
Sawamura commented: Nice +4
dnk commented: fast.. +4