Jx_Man 987 Nearly a Senior Poster Featured Poster

Yes. Database file.
What kind of database you're using in this program? access?

Jx_Man 987 Nearly a Senior Poster Featured Poster
november_pooh commented: Great link +3
Jx_Man 987 Nearly a Senior Poster Featured Poster

What kind of database you're using?
Can you post it here?

Jx_Man 987 Nearly a Senior Poster Featured Poster

You're Welcome, Dude
Then please mark this thread solved

Jx_Man 987 Nearly a Senior Poster Featured Poster

I need help for my program..
I add a search the Adodc in my program with a combo box category,
but when i run the program and search...
the category "ID" not searching..

You said that category ID is not searching. How about another category?
If other category is successful to search then make sure that your column named "ID" is exist in your table.
But if ID is exist, you may see your input text to search.
Since you used '=' operator to compare input text, you must input right value (i mean same with value that store in your table).

Your code looks so crowded, so i modified a little with select-case :

Private Sub Command1_Click()
If Text1.Text = "" Then
    MsgBox "Type To Search"
Else
   Select Case Combo1.Text
        Case "ID"
            Form2.Adodc1.Recordset.Filter = "ID='" & Text1.Text & "'"
        Case "Surname"
            Adodc1.Recordset.Filter = "Surname='" & Text1.Text & "'"
        Case "First Name"
            Adodc1.Recordset.Filter = "FirstName='" & Text1.Text & "'"
        Case "Middle Name"
            Adodc1.Recordset.Filter = "MiddleName='" & Text1.Text & "'"
    End Select
End If
End Sub
Jx_Man 987 Nearly a Senior Poster Featured Poster

please help i want my textbox phoneno to allow only numbers and only 10 numbers to b allowed please guide me using VB.NET 2008

harshi sarvaiya..make your own thread here.
There are many members will help you more..

Jx_Man 987 Nearly a Senior Poster Featured Poster

Please gave me some idea

Use Sum function in your sql query.

or Code Thx

modified as you needed :

Private Sub Command1_Click()
    Dim Conn As New ADODB.Connection
    Dim rs As New ADODB.Recordset
    Dim sConnect As String
     
    sConnect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "emp.mdb"
    'Replace emp with your file name
    Conn.Open sConnect
    rs.Open "select sum(quantity) from purchase", Conn, adOpenDynamic, adLockPessimistic
    Msgbox rs.Fields(0).Value
    rs.Close
    Conn.Close
End Sub
Jx_Man 987 Nearly a Senior Poster Featured Poster

in vb6 you can use Replace() function :

Replace(YourStringHere, " ", "")
Jx_Man 987 Nearly a Senior Poster Featured Poster
Jx_Man 987 Nearly a Senior Poster Featured Poster

Anyways, May I ask, where should I insert the msgbox code so that everytime the user enters letters or other numbers except from 1,2 and 3 of course, a pop-up msg will show up telling that he entered "Invalid Code" ?

Put in trapping case :

Private Sub Text1_KeyPress(KeyAscii As Integer)
    Select Case KeyAscii
        Case 48 To 57, 8 '0-9 and backspace
        'Let these key codes pass through
        Case Else
        'All others get trapped
        KeyAscii = 0 ' set ascii 0 to trap others input
        MsgBox "Invalid Code" 'Put your message here
    End Select
End Sub
Jx_Man 987 Nearly a Senior Poster Featured Poster

See this following code :

For i As Integer = 0 To ListBox1.SelectedIndices.Count - 1
   ListBox1.Items.RemoveAt(ListBox1.SelectedIndex)
Next

Or you use this too :

Do While (ListBox1.SelectedItems.Count > 0)
   ListBox1.Items.Remove(ListBox1.SelectedItem)
Loop
kingsonprisonic commented: No Need of loop.... -1
Jx_Man 987 Nearly a Senior Poster Featured Poster

See if this help :

Private Sub Command1_Click()
List1.Clear
x = 0
For j = 1 To Len(Trim(Text1.Text))
    kt1 = Mid(Trim(Text1.Text), j, 1)
    kta = kta + kt1
    If kt1 = Chr(32) Then
        x = x + 1
        List1.AddItem Trim(kta)
        kta = ""
    End If
Next j

If x >= 0 Then List1.AddItem Trim(kta)

End Sub
EkoX commented: Worked really nice :D +1
Jx_Man 987 Nearly a Senior Poster Featured Poster

Try this :

Dim ctrAs Control

For Each ctr In Me.Controls
   If TypeOf ctr Is TextBox Then
      If ctr.Text= vbNullString Then
         MsgBox "Textbox empty"

         ctr.SetFocus

         Exit Sub

      End If
  End If
Next ctr
hkdani commented: Excellent suggestions based on in depth knowledge of the language. +5
Sturdy commented: It's a wonderful code sir :) +2
Jx_Man 987 Nearly a Senior Poster Featured Poster

when the input is 12 years and 6 months I want the program to print teenager
I'm not sure how to do that

Input should be 12.6 to get right result.
so you can concatenate textbox1 (for year) and textbox2 (for month) :

Private Sub Command1_Click()
Select Case Val(Text1.Text) & "." & Val(Text2.Text)
    Case 0 To 1
        MS_lbl_category.Text = CStr("infant")
    Case 1 To 2
        MS_lbl_category.Text = CStr("toddlerI")
    Case 2 To 6
        MS_lbl_category.Text = CStr("kindergarten")
    Case 6 To 12
        MS_lbl_category.Text = CStr("child")
    Case 12 To 19
        MS_lbl_category.Text = CStr("teenager")
    Case 19 To 25
        MS_lbl_category.Text = CStr("young adult")
    Case 25 To 40
        MS_lbl_category.Text = CStr("adult")
    Case 40 To 60
        MS_lbl_category.Text = CStr("middle aged")
    Case 60 To 120
        MS_lbl_category.Text = CStr("senior citizen")
    Case Else
        MS_lbl_category.Text = CStr("Are you kidding ?")
End Select
End Sub
Jx_Man 987 Nearly a Senior Poster Featured Poster

I have a project of 2 forms and on the 2nd form I want to create a button which when clicked, returns you to the 1st form and all values in the 3 textboxes disappear. Please help!

I don't get what you want exaclty.
You want get back from Form2 to Form1 but you not specify that both of forms active or not.
If both of forms active then just focus to form1 like ChrisPadgham said ( Form1.SetFocus ) and set textboxes to empty ( Textbox1.Text = "" ).
But if just form2 is currently active right now then call form1 again ( Form1.Show ) and Clear the textboxes.

Jx_Man 987 Nearly a Senior Poster Featured Poster

How to connect datagrid from database using adodb connection. so that the records in the database will display in the datagrid. I have category here that i want to display to datagrid: ID, LName, FName, GLevel. I need a code for that. THANK YOU!

Connect to what database?

Jx_Man 987 Nearly a Senior Poster Featured Poster

Highlight item which index in textbox.
Try this :

Private Sub Command1_Click()
List1.Selected(Text1.Text) = True
End Sub
Jx_Man 987 Nearly a Senior Poster Featured Poster

See if this helps :

Private Sub ListFiles(strPath As String, Optional Extention As String)
'Leave Extention blank for all files
    Dim File As String
       
    If Right$(strPath, 1) <> "\" Then strPath = strPath & "\"
       
    If Trim$(Extention) = "" Then
        Extention = "*.*"
    ElseIf Left$(Extention, 2) <> "*." Then
        Extention = "*." & Extention
    End If
       
    File = Dir$(strPath & Extention)
    Do While Len(File)
        List1.AddItem File
        File = Dir$
    Loop
End Sub

To get all files :

Private Sub Command1_Click()
ListFiles "D:\musicfolder", "*" ' Or ListFiles "D:\musicfolder", "" leave it blank to get all files
End Sub

Just get mpg files :

Private Sub Command1_Click()
ListFiles "D:\musicfolder", "mpg" 'mpg files
End Sub
Jx_Man 987 Nearly a Senior Poster Featured Poster

jxman :hmm...
i have not started make specific datareport, i've got confused in make a code,
i can make specific data in txt.file not in datareport in vb6
did it have a same code..???

Make some effort dude.. try to see another related thread on this section..You'll find a lot info there. After it giving a try. Give feedback here if you found a problem, error, etc.

Jx_Man 987 Nearly a Senior Poster Featured Poster

Like i said before to manipulate your SQL Statment :

openrstJCcaseInfo "select * from JCcaseInfo like " & "'%" & txtsearch.Text & "%'"
Estella commented: Good Point :D +4
Vega_Knight commented: :D +2
Jx_Man 987 Nearly a Senior Poster Featured Poster

I don't understand what you want exactly.
You want to swap items index?

Jx_Man 987 Nearly a Senior Poster Featured Poster

Manipulate your sql query to receive input from textbox and put the code in textbox_change() event..

Private Sub Text1_Change()
' your code here
End Sub
Jx_Man 987 Nearly a Senior Poster Featured Poster

Look for a file named MSDE.DLL
It should be in C:\Program Files\Common Files\designer

If it's not there, you'll need to extract it from the VB install CD. Then use the command below to register it.

If it is there, register it again. copy and paste this command into Start->run and press enter:

regsvr32 "C:\Program Files\Common Files\designer\msde.dll"

Jx_Man 987 Nearly a Senior Poster Featured Poster

You can access form control using second form name as object.

Put this code in any event you want :

Form2.Label1.Caption = Label1.Caption
Jx_Man 987 Nearly a Senior Poster Featured Poster

Right Click On project name -> Add -> Data Environment

Jx_Man 987 Nearly a Senior Poster Featured Poster

How far you doing this? Give some effort..

Jx_Man 987 Nearly a Senior Poster Featured Poster

So what the problem is?
How far you doing this? showing your effort.

Jx_Man 987 Nearly a Senior Poster Featured Poster

Try this :

Private Sub Command1_Click()
    MsgBox Printer.DeviceName
End Sub
Jx_Man 987 Nearly a Senior Poster Featured Poster

Just trap the ascii code, So user only can input numbers.
This following code just accept numbers input only :

Private Sub Text1_KeyPress(KeyAscii As Integer)
    Select Case KeyAscii
        Case 48 To 57, 8 '0-9 and backspace
        'Let these key codes pass through
        Case Else
        'All others get trapped
        KeyAscii = 0 ' set ascii 0 to trap others input
    End Select
End Sub
ynehs commented: thumbs up! +0
Jx_Man 987 Nearly a Senior Poster Featured Poster

>>If the optInst is selected at line 31 then chkMast or chkDoct needed to be weighted by 1.3.
You mean if RB Instructor is selected then checkbox master and doctor should be checked?

Private Sub optInst_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles optInst.CheckedChanged
 
lblSalOutput.Text = FormatCurrency(CInt(sumTotal()))
    If optInst.Checked = True Then
        chkMast.Checked = True
        chkDoct.Checked = True
    End If
End Sub
Jx_Man 987 Nearly a Senior Poster Featured Poster

would you help me, how to create table (ACCESS) with primary key in visual Basic 6?

Well, your code is not completed since you never add all created columns to catalog(catDB) and also missing "End With" statement.
To create PK you need to append a new key :
I add two lines code below (with comments):

' Now add the rest of the columns
With tblNew
' Create fields and append them to the
' Columns collection of the new Table object.
With .Columns
    .Append "NOMBER", adVarWChar
    .Append "NAME", adVarWChar
    .Append "ISSUE_ATE", adDate
    .Append "BIRTH_DATE", adDate
    .Append "GAJI", adSingle
End With

'Create and Append a new key. Note that we are merely passing
'the "NOPOL" column as the source of the primary key. This
'new Key will be Appended to the Keys Collection of "Data Peserta"
.Keys.Append "PrimaryKey", adKeyPrimary, "NOPOL" ' Add this line to append PK

End With

'Append the newly created table to the Tables Collection
catDB.Tables.Append tblNew ' Since you didn't append table column to catDB
Jx_Man 987 Nearly a Senior Poster Featured Poster

As ChrisPadgham said..that is a simplest way.
This following is other way (But Still needed to use Looping):

For Each controlx In Form1.Controls
    If TypeOf controlx Is TextBox Then controlx.BackColor = vbRed
Next controlx
Jx_Man 987 Nearly a Senior Poster Featured Poster
Jx_Man 987 Nearly a Senior Poster Featured Poster

You're welcome.
Okay don't forget to mark this thread as solved.

Jx_Man 987 Nearly a Senior Poster Featured Poster

Wow..you even don't know how to add reference. :D
Go to Project->Reference->Microsoft Excel 12.0 Object Library

Jx_Man 987 Nearly a Senior Poster Featured Poster

Okay. This some code :
You need add reference Microsoft Excel Library.

Private Sub Command1_Click()
    Dim XcLApp     As Object
    Dim XcLWB      As Object
    Dim XcLWS      As Object
    
    Set XcLApp = CreateObject("Excel.Application")
    Set XcLWB = XcLApp.Workbooks.Add
    Set XcLWS = XcLWB.Worksheets.Add
    
    XcLWS.Range(Addres_Excel(1, 1)).Value = "Test string"
    
    XcLApp.Visible = True
    'XcLWS.PrintOut
End Sub
Public Function Addres_Excel(ByVal lng_row As Long, ByVal lng_col As Long) As String
    Dim modval As Long
    Dim strval As String
    modval = (lng_col - 1) Mod 26
    strval = Chr$(Asc("A") + modval)
    modval = ((lng_col - 1) \ 26) - 1
    If modval >= 0 Then strval = Chr$(Asc("A") + modval) & strval
    Addres_Excel = strval & lng_row
End Function
Jx_Man 987 Nearly a Senior Poster Featured Poster

what do you mean with simple diagram or flowchart?

Jx_Man 987 Nearly a Senior Poster Featured Poster

See if this help :

Shell("shutdown -s") 'Shutdown
Jx_Man 987 Nearly a Senior Poster Featured Poster

First your database just contain user table only.
I suggesting you to make complete your database.
It useless when your database is not completed.

Jx_Man 987 Nearly a Senior Poster Featured Poster

See if this helps :

Public Function ChangeFileExt(ByVal aFilename As String, ByVal NewExt As String) As Boolean
Dim p As Long
Dim bp As Long
Dim nFileName As String

On Error Resume Next
ChangeFileExt = False
If aFilename = "" Then Exit Function
p = 0
Do
    bp = p
    p = InStr(p + 1, aFilename, ".", vbBinaryCompare)
Loop Until p = 0

If bp > 0 Then
    nFileName = Left(aFilename, bp - 1)
Else
    nFileName = aFilename
End If

nFileName = nFileName & "." & NewExt

Err.Clear

Name aFilename As nFileName

If Err.Number = 0 Then ChangeFileExt = True

End Function

' Change file type
Private Sub Command1_Click()
Call ChangeFileExt("D:\test.txt", "jx") ' from .txt become .jx
End Sub

Your case :

Text1.Text = "D:\test.txt"
Text2.Text = "jx"
Private Sub Command1_Click()
Call ChangeFileExt(Text1.Text, Text2.Text) 
End Sub
Jx_Man 987 Nearly a Senior Poster Featured Poster

Thanks Brother I am very Thanks full to you
Its work
Good bless you
Raza Mughal

You're Welcome.
Please Mark this thread as Solved :D

Jx_Man 987 Nearly a Senior Poster Featured Poster

How far you doing this?

Jx_Man 987 Nearly a Senior Poster Featured Poster

This how far i'm doing. But i don't know how to check if last 3 character is number?

Use IsNumeric() function :

Private Sub Command1_Click()
Dim First4Char, Last3Char As String
First4Char = Mid(Text1.Text, 1, 4)
Last3Char = Mid(Text1.Text, 5, 7)
If Len(Text1.Text) <= 7 Then
    If First4Char <> "ABCD" Then
        MsgBox "Wrong"
    Else
        If Not IsNumeric(Last3Char) Then
            MsgBox "Wrong Input"
        Else
            ' Action if text is accepted
        End If
    End If
End If
End Sub
Sturdy commented: It worked very nice. :D +2
Jx_Man 987 Nearly a Senior Poster Featured Poster

You can use Mid() , Left() or Right() function to get The first four characters and the last 3 characters and Use Len() for the length of text.

Jx_Man 987 Nearly a Senior Poster Featured Poster

I mean, when i put cursor (click) in some text i will know where the cursor is.

Okay. See if this helps :

Private Sub Text1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Text1.SelLength = 0 Then
    lCurPos = Text1.SelStart
Else
    lCurPos = Text1.SelStart + Text1.SelLength
End If
Label1.Caption = "Cursor Position " & lCurPos
End Sub
Sturdy commented: It worked sir. :D +1
Sawamura commented: Good +3
Jx_Man 987 Nearly a Senior Poster Featured Poster

what you mean about position in text at textbox?
please give more information.

Jx_Man 987 Nearly a Senior Poster Featured Poster

See if this helps :
Need 1 Module and 1 Button.

In Module :

'Author : Gernan Mejia Aka DJ Unreal 303
'Language : VB5, VB6
'Operating Systems  : Windows 9x, NT, 2000, Me, XP

'-------------------------------------------------------
Type PROCESSENTRY32
    dwSize As Long
    cntUsage As Long
    th32ProcessID As Long
    th32DefaultHeapID As Long
    th32ModuleID As Long
    cntThreads As Long
    th32ParentProcessID As Long
    pcPriClassBase As Long
    dwFlags As Long
    szexeFile As String * 260
End Type
'-------------------------------------------------------
Declare Function OpenProcess Lib "kernel32.dll" (ByVal dwDesiredAccess As Long, _
ByVal blnheritHandle As Long, ByVal dwAppProcessId As Long) As Long

Declare Function ProcessFirst Lib "kernel32.dll" Alias "Process32First" (ByVal hSnapshot As Long, _
uProcess As PROCESSENTRY32) As Long

Declare Function ProcessNext Lib "kernel32.dll" Alias "Process32Next" (ByVal hSnapshot As Long, _
uProcess As PROCESSENTRY32) As Long

Declare Function CreateToolhelpSnapshot Lib "kernel32.dll" Alias "CreateToolhelp32Snapshot" ( _
ByVal lFlags As Long, lProcessID As Long) As Long

Declare Function TerminateProcess Lib "kernel32.dll" (ByVal ApphProcess As Long, _
ByVal uExitCode As Long) As Long

Declare Function CloseHandle Lib "kernel32.dll" (ByVal hObject As Long) As Long

In Form :

'-------------------------------------------------------
Public Sub KillProcess(NameProcess As String)
Const PROCESS_ALL_ACCESS = &H1F0FFF
Const TH32CS_SNAPPROCESS As Long = 2&
Dim uProcess  As PROCESSENTRY32
Dim RProcessFound As Long
Dim hSnapshot As Long
Dim SzExename As String
Dim ExitCode As Long
Dim MyProcess As Long
Dim AppKill As Boolean
Dim AppCount As Integer
Dim i As Integer
Dim WinDirEnv As String
       
       If NameProcess <> "" Then
          AppCount = 0

          uProcess.dwSize = Len(uProcess)
          hSnapshot = CreateToolhelpSnapshot(TH32CS_SNAPPROCESS, 0&) …
Jx_Man 987 Nearly a Senior Poster Featured Poster

>>what connection will i use and how and sample codes.
You want to connect with access 2007 or you want to make report of your db?
Anyway how far you doing this?

Jx_Man 987 Nearly a Senior Poster Featured Poster

Also CheckOnClick was not necessary because I already have that as “True” from the properties in designer.

Okay. I don't know it if you already set it.

So this is only working for items 1 to 5 and not for my own 68 items.

Yes, This only working for items with value 1 to 5. I just give the example. You modified it as you wish.

Jx_Man 987 Nearly a Senior Poster Featured Poster

Try this

Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    For i As Integer = 1 To 5
        CheckedListBox1.Items.Add(i)
    Next

    CheckedListBox1.CheckOnClick = True 'Checked item when you select it
End Sub

Private Sub CheckedListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckedListBox1.SelectedIndexChanged
    If CheckedListBox1.SelectedItem.ToString = "1" Then
        Button1.Enabled = True
    End If   
End Sub