Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Personal Todo list


Eevee204
 Share

Recommended Posts

Simple Todo List

Features:
- Add a Todo
- Remove a Todo
- Clear a Todo
- Choose a colour
- Open/Close using the keys 1 and 2

Soon to add:

Example:
![](http://gyazo.com/e675ef6c6a45b8f5bcdae5d9ec787dec.png)

Button artwork below:
![](http://gyazo.com/9f9f05ed4ce3163999945d58bfcdeda6.png)![](http://gyazo.com/302b108fc0999be8c935bf322dda1a84.png)![](http://gyazo.com/1e87cd5975eb7264e4304edc6bac3782.png)

Okay, so now we'll get to adding the code and the controls.

First thing to do is add the controls and give them a name: (Change these in the properties)
Picturebox = grpTodo
Label = Default
Listbox = lstTodo
Textbox = txtTodo
3 Picturebox(for buttons) = picTodoAdd, picTodoRemove, picTodoClear
Combobox = cmbTodo

Now the layout is done, get to the code:
Double click on any control on your form and press Ctrl + F and type 'KeyAscii' and you'll find the code:```
Private Sub Form_KeyPress(KeyAscii As Integer)
```
Underneath is add the code:
```
    'Eevees todo list box
    If KeyAscii = vbKey1 Then
        grpTodo.Visible = False
    ElseIf KeyAscii = vbKey2 Then
        grpTodo.Visible = True
    End If
```
Now go back to the form and click on the Add Todo picture and in between:
```
Private Sub picTodoAdd_Click()

End Sub
```
Add:

```
'Eevees Todo List
    If txtTodo.text = "" Then 'This line and the below line make sure they enter something
        txtTodo.text = "Please type something first."
    Else
    ' Setting the colours for the box
        If cmbTodo.text = "Black" Then
            lstTodo.ForeColor = RGB(0, 0, 0) 'Black
            lstTodo.AddItem txtTodo.text

        ElseIf cmbTodo.text = "Red" Then
            lstTodo.ForeColor = RGB(255, 0, 0) 'Red
            lstTodo.AddItem txtTodo.text

        ElseIf cmbTodo.text = "Yellow" Then
            lstTodo.ForeColor = RGB(255, 255, 0) 'Yellow
            lstTodo.AddItem txtTodo.text

        ElseIf cmbTodo.text = "Green" Then
            lstTodo.ForeColor= RGB(34, 177, 76) 'Green
            lstTodo.AddItem txtTodo.text
        End If
    End If
```
Now go back to the form and double click the Remove Todo and in between:
```
Private Sub picTodoRemove_Click()

End Sub
```
Add:

```
Private Sub picTodoRemove_Click()

    If lstTodo.ListCount = 0 Then
        lstTodo.AddItem ("Please add an item...")
        lstTodo.ListIndex = 0 'Select an item automatically
    Else

        lstTodo.RemoveItem lstTodo.ListIndex 'Removes an item that is selected
        lstTodo.ListIndex = lstTodo.ListCount - 1
    End If
End Sub

```
For the final button go back to the form and click on the Clear and in between:
```
Private Sub picTodoClear_Click()

End Sub
```
Add:

```
lstTodo.Clear 'Removes everything from the listbox
```
Now for the colour change:
On the main form click anyway to get back to the code and press Ctrl + F and type in: FOrm_load.

Below:

```
Private Sub FOrm_load()
```
Add:

```
    'Eevees Todo List - Adding items to the combobox
    cmbTodo.AddItem ("Black")
    cmbTodo.AddItem ("Red")
    cmbTodo.AddItem ("Yellow")
    cmbTodo.AddItem ("Green")
```
This will load up the combobox with colours.

If you want to add your own colours

Add a new line below:

```
cmbTodo.AddItem ("Colour")
```
And to get the colour to work below:
```
        ElseIf cmbTodo.text = "Green" Then
            lstTodo.AddItem = RGB(34, 177, 76) 'Green
            lstTodo.AddItem txtTodo.text
        End If
```

Add:
```
        ElseIf cmbTodo.text = "Colour" Then
            lstTodo.AddItem = RGB(0, 0, 0) 'Colour
            lstTodo.AddItem txtTodo.text
        End If
```
I find it helps to get the colours off paint.

![](http://gyazo.com/f15f8a94cf98764f659c38da4fdfbd29.png)

If there are any problems or doesn't work just message, this is my first tutorial so hopefully it works!
Code was done by me and buttons done by James Burton. :-)

I'm always open to feedback also! :D
Link to comment
Share on other sites

@Eevee204:

> I find it helps to get the colours off paint.
>
> ![](http://gyazo.com/f15f8a94cf98764f659c38da4fdfbd29.png)

Or you can simply use [ChooseColor()](http://msdn.microsoft.com/en-us/library/windows/desktop/ms646912%28v=vs.85%29.aspx) in a [VB6-specific](http://stackoverflow.com/questions/6324883/a-color-picker-control-for-visual-basic-6-vb6) fashion.

Yours faithfully
  Stephan.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...