Jx_Man 987 Nearly a Senior Poster Featured Poster

Add reference : Microsoft CDO For Windows 2000 Library
5 textboxes, 1 button
Try This :

Private Sub Command1_Click()
    
    On Error GoTo ErrHandler
    
    Dim oConfig As New CDO.Configuration
    Dim oMsg As New CDO.Message
    
    Label1.Caption = ""
    
    With oConfig.Fields
       .Item(cdoSendUsingMethod) = cdoSendUsingPort
       .Item(cdoSMTPServerPort) = 465
       .Item(cdoSMTPServer) = "smtp.mail.yahoo.com"
       .Item(cdoSMTPAuthenticate) = cdoBasic
       .Item(cdoSendUserName) = txtSender.Text
       .Item(cdoSendPassword) = txtPassword.Text
       .Item(cdoSendEmailAddress) = txtSender.Text
       .Item(cdoSMTPUseSSL) = 1
       .Update
    End With
    
    With oMsg
       .Configuration = oConfig
       .Subject = txtSubject.Text
       .To = txtAddress.Text
       .From = txtSender.Text
       .HTMLBody = txtMessage.Text
       .Send
    End With
    
    Set oMsg = Nothing
    Set oConfig = Nothing
    
    Label1.Caption = "Email Sent"
    Exit Sub

ErrHandler:

    MsgBox Err.Description, vbCritical, "Error"

End Sub
Jx_Man 987 Nearly a Senior Poster Featured Poster

ok, i have this code:

If Text1 = KeyPress Then
Label = CommonDialog1.FileName
End If

but i have an error with KeyPress event :C

This not a code i asking for..
I asked your code for save or load data from database.
or you didn't have a code for save or load data?
and for your code how you can assign a textbox with keypress ? and you try to get file name without select it.

Jx_Man 987 Nearly a Senior Poster Featured Poster

You said that you only can preview data on data grid when you load your form.
So the code that you using to preview data at load form, make it like procedure/function.
You just call the function to refresh datagrid from anywhere.
After insert, edit or delete data or on refresh button.

Just put your preview code into procedure/function

Public Sub RefreshDataGrid()
   ... 'Your query to preview data on datagrid
End Sub

You can call that procedure at any event to refresh data grid

Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
    ... 'your code to insert data
    RefreshDataGrid ' call refreshdatagrid function to refresh data on datagrid after insert statment
End Sub

Do the same thing for edit or delete event or refresh button.

Jx_Man 987 Nearly a Senior Poster Featured Poster

how to make datagrid automaticly load data form database after insert new data..data grid only load after i relaunch my application...do i need create refresh button or anything else??

I suggest to make a function to preview data. so you can call it anywhere. after insert, edit or delete data or refresh button .

Jx_Man 987 Nearly a Senior Poster Featured Poster

as debasisdas said, use common dialog control

First you need to add the component:
* Project > Components
* On the Controls tab, choose Microsoft Common Dialog Control 6.0 (SP6)

Now on your form, add the new Common Dialog control from the toolbox

this following code to use common dialog :

Private Sub btnBrowse_Click()
    CommonDialog1.Filter = "All files (*.*)|*.*"
    CommonDialog1.DialogTitle = "Select File"
    CommonDialog1.ShowOpen
    
    MsgBox CommonDialog1.FileName
End Sub
Jx_Man 987 Nearly a Senior Poster Featured Poster

as debasisdas said, use common dialog control

First you need to add the component:
* Project > Components
* On the Controls tab, choose Microsoft Common Dialog Control 6.0 (SP6)

Now on your form, add the new Common Dialog control from the toolbox

this following code to use common dialog :

Private Sub btnBrowse_Click()
    CommonDialog1.Filter = "All files (*.*)|*.*"
    CommonDialog1.DialogTitle = "Select File"
    CommonDialog1.ShowOpen
    
    MsgBox CommonDialog1.FileName
End Sub
Sturdy commented: Thank you.. +1
Jx_Man 987 Nearly a Senior Poster Featured Poster

If this thread already answered then please mark this thread as solved.

Jx_Man 987 Nearly a Senior Poster Featured Poster

okay..
post your save code and load code..
i'll fix it with open dialog code.

Jx_Man 987 Nearly a Senior Poster Featured Poster

okay..
post your save code and load code..
i'll fix it with open dialog code.

Jx_Man 987 Nearly a Senior Poster Featured Poster

P.manidas : its a great to find the answer..:)
Androidz : I tried the code and i got same errors (i never try the code before). I realized that i could only get last textbox value. When textbox created, its just create one textbox (even you create more than 1 textboxes), so we need to identify all created textboxes. I was try to use typeofcontrol to identify the textboxes and code from P.manidas is complete the answer with Instr function (thanks to P.manidas) :)

Jx_Man 987 Nearly a Senior Poster Featured Poster

Hi,
Get the path using opendialog control, then save the path to database.
When you want to show it, just load from database and show it using picture box.
Just it.

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

Actually you can know how much textboxes was made from the start when user input how much he want to create a textboxes
You can use it..
Store it on global variable and use it when you try to get textboxes value.
ex :

Dim ctr as Integer ' put this declaration at top of all codes
' on button create textboxes code event
...
ctr = text1.Text ' user input how many textboxes will made.. if he input 2 then two textboxes will created..from this you can know how much the textboxes .. 
...


' on button load event (button to get textbox value)
for j = 0 to ctr - 1 ' index star from 0 to ctr (user input) ctr is global variable
  a = a + txt(j).Text ' retrieve all textbox value and add it to a
next j

After read second page i found that you have variable to store how much user want to create textboxes. that is m_jobs.
so you can set as global variable and use it when you try to get textbox value.

for j = 0 to m_jobs - 1 ' index star from 0 to m_jobs (user input) 
  a = a + txt(j).Text ' retrieve all textbox value and add it to a
next j

Or you still use ctr as global variable but you still need to assign value from m_jobs

' at created textbox code
ctr = m_jobs

so you …

Jx_Man 987 Nearly a Senior Poster Featured Poster

Okay..
1. Dont try to get textbox value while it created on the form. (you do this in page 1)
2. separate your textbox created codes with your get value from text box codes.
3. Put this following code on button click event.

for j = 0 to ctr ' index star from 0 to ctr (user input)
  a = a + txt(j).Text ' retrieve all textbox value and add it to a
next j

4. You said that ctr is user input. then how you get ctr value?

Jx_Man 987 Nearly a Senior Poster Featured Poster

Great..Don't Forget to mark this thread as solved.

Jx_Man 987 Nearly a Senior Poster Featured Poster

if you follow my code correctly than all will running nice..

Jx_Man 987 Nearly a Senior Poster Featured Poster

what u men..do i need use select statment...

Yes.. before insert your data, you need to search the ID in database..
if Id exist in database then show an error message..

Jx_Man 987 Nearly a Senior Poster Featured Poster

transperncy form in mdi form is working to me..
put the same code in mdi form..

and for the manifest file..
if the manifest file is not working then your exe file cannot shown up..
if exe file appear then manifest file is working.

Jx_Man 987 Nearly a Senior Poster Featured Poster

what error said to you?

Jx_Man 987 Nearly a Senior Poster Featured Poster

i dont know how to use manifest file...i have code of manifest and i have made manifest file, but i dont know the way how to use that...can u plz tell me..
i have manifest file in c with this path and name" C:/vb6/vb6.exe.manifest"
will you please tell me the way how to use that with vb and controls.

Put manifest file on your project folder.
ex : your exe project name is EmployeeData.exe then rename manifest file into EmployeeData.exe.manifest then running EmployeeData.exe. you will see the changed.

and the code u have wrote above is not working on Midi Child Form....

use your midi formname instance of me..

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

are you read my posts and any codes that i provides?

Jx_Man 987 Nearly a Senior Poster Featured Poster

yes,,you can make your all control seems like windows version..means in xp it looks in xp style or in win 7 its likes win 7..
just add manifest file on your project..

Jx_Man 987 Nearly a Senior Poster Featured Poster

just select id from database..if id key already saved in database then give an error message..

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

you can use API files to do this.

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

transparency Window and all controls?

Jx_Man 987 Nearly a Senior Poster Featured Poster

what type of your field?

Jx_Man 987 Nearly a Senior Poster Featured Poster

you must put the code in the procedure, function or event.

Jx_Man 987 Nearly a Senior Poster Featured Poster

what the error says to you?

Jx_Man 987 Nearly a Senior Poster Featured Poster

You're Welcome...
Please Mark this thread as solved.
We've helps you several times but you never mark your thread as solved.
Mark thread as solved helping another member to learn from your threads.

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

what you mean about not working?

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

j on first page is for adding text boxes during run time. and on the second page, he tried to get value from textboxes while the textboxes adding on the form.
If we try to get textbox value while textbox created then we never get user input.
On page two he said to get user input and when he press a button then he will get textbox value.
If he put the code on the button event then where is j come from? ;)

Jx_Man 987 Nearly a Senior Poster Featured Poster

i'm not try to remember all of it..just try to understand how to use it and do a lot of practice.
ex : delete query is from sql language. there are single quote in the statment.
delete from login where login_id = '1' , when you use it on vb you will know that delete statment still need single quote. that i mean about understanding.
if you understand automatically you'll remember it :)

Happy coding and don't forget to mark this thread as solved.

Jx_Man 987 Nearly a Senior Poster Featured Poster

ctr is a user input.. txt(j).Text , what is j ?? j is not using in your looping. so it will give u an error.
if you want to use j then your code should be like this :

Dim j as Integer
For j = 0 To ctr - 1
    a = txt(j).Text   
Next j

but if you want to use ctr in your looping then your code should be like this :

For ctr = 0 To ctr - 1
    a = txt(ctr).Text  ' j changed with ctr
Next ctr
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

missing single quote :

Dim cmd2 As New OleDb.OleDbCommand("DELETE FROM tblPNGATSAExecutive WHERE ExecutiveID = '" & lvData.Items(ItemNo).SubItems(0).Text & "'", conn)
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

You can use SaveSetting()

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

@ Andre : thanks for the correction about listbox (you right index in lisbox start with 0) but i'm not sure about listview. if you minus listitems.count with 1 then it will skip the last item when you adding the items.

Jx_Man 987 Nearly a Senior Poster Featured Poster

You're Welcome.. :)
Don't forget to mark this thread as solved.

Happy Coding.

Jx_Man 987 Nearly a Senior Poster Featured Poster

post your last code and what the error tell to you?

Jx_Man 987 Nearly a Senior Poster Featured Poster

don't forget to mark this thread as solved :)

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

THANKS JX...ITS WORKING VERY WELL, BUT STILL IT IS ERRORING,WHEN THERE IN NO ANY RECORD IN LISTVIEW..

"Object Variable or with block variable not set."

Just check the items, if there are no data in listview then display a message.

If ListView2.ListItems.Count > 0 Then
    If CheckId(ListView2.SelectedItem) = True Then
        SQlQuery = "DELETE FROM Users WHERE Id_User ='" & Trim(ListView2.SelectedItem) & "'"
        Conn.Execute SQlQuery, , adCmdText
    Else
        MsgBox "Record not find"
    End If
Else
    MsgBox "no data on list view"
End If

where='" & Trim(Id)" what is it's functionalty

Trim used to remove white space at the beginning and end of a string.
Ex : Trim(" Daniweb ") -> Result : "Daniweb"

Jx_Man 987 Nearly a Senior Poster Featured Poster

no i have used only one, i have changed the concept..now when user will add new records, the listview will b clear, and new records will b added to list and when user will update that records, list will b refreshed and it will show old and new both records now, if anyone wants to change anything, then i have kept the button of delete, he can delete any previous or new record...

i think its a better option...what do u say?

Yes.. Its a better option.. Nice idea :)

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