Absolutely! Creating a full-featured MS Project clone is a large undertaking, but I can help you get started with a solid foundation in VB.NET using Windows Forms and MS Access. This will give you a basic project management tool with a Gantt chart-like interface, task management, and database connectivity. You can then extend it as needed.
Below is a step-by-step guide to create a basic MS Project-like application in VB.NET with MS Access as the backend.
1. Set Up the Database (MS Access)
Create a new Access database (e.g., ProjectManager.accdb) with the following tables:
Table: Projects
| Field Name | Data Type |
|---|
| ProjectID | AutoNumber |
| ProjectName | Text |
| StartDate | Date/Time |
| EndDate | Date/Time |
Table: Tasks
| Field Name | Data Type |
|---|
| TaskID | AutoNumber |
| ProjectID | Number |
| TaskName | Text |
| StartDate | Date/Time |
| EndDate | Date/Time |
| Duration | Number |
| Predecessor | Number |
2. Create a New VB.NET Windows Forms Project
- Open Visual Studio.
- Create a new Windows Forms App (.NET Framework) project in VB.NET.
3. Add References
- Add a reference to
System.Data.OleDb for Access database connectivity.
4. Design the Main Form
- Add a DataGridView for tasks.
- Add controls for project selection, adding/editing tasks, and a simple Gantt chart (can be another DataGridView or a custom control).
- Add buttons: Add Project, Add Task, Edit Task, Delete Task, Refresh.
5. Sample Code: Database Connection Module
Imports System.Data.OleDb
Module DBHelper
Public connString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=ProjectManager.accdb;Persist Security Info=False;"
Public conn As New OleDbConnection(connString)
Public Function GetDataTable(query As String) As DataTable
Dim dt As New DataTable()
Try
conn.Open()
Dim cmd As New OleDbCommand(query, conn)
Dim da As New OleDbDataAdapter(cmd)
da.Fill(dt)
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
conn.Close()
End Try
Return dt
End Function
Public Sub ExecuteNonQuery(query As String)
Try
conn.Open()
Dim cmd As New OleDbCommand(query, conn)
cmd.ExecuteNonQuery()
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
conn.Close()
End Try
End Sub
End Module
6. Sample Code: Main Form (Form1.vb)
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
LoadProjects()
End Sub
Private Sub LoadProjects()
Dim dt As DataTable = GetDataTable("SELECT * FROM Projects")
ComboBoxProjects.DataSource = dt
ComboBoxProjects.DisplayMember = "ProjectName"
ComboBoxProjects.ValueMember = "ProjectID"
End Sub
Private Sub LoadTasks()
If ComboBoxProjects.SelectedValue IsNot Nothing Then
Dim projectId As Integer = ComboBoxProjects.SelectedValue
Dim dt As DataTable = GetDataTable($"SELECT * FROM Tasks WHERE ProjectID={projectId}")
DataGridViewTasks.DataSource = dt
DrawGanttChart(dt)
End If
End Sub
Private Sub ComboBoxProjects_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBoxProjects.SelectedIndexChanged
LoadTasks()
End Sub
' Add code for Add/Edit/Delete Task buttons here
Private Sub DrawGanttChart(tasks As DataTable)
' For simplicity, use another DataGridView to show Gantt chart
' You can enhance this with custom drawing for a real Gantt chart
DataGridViewGantt.Rows.Clear()
For Each row As DataRow In tasks.Rows
Dim idx = DataGridViewGantt.Rows.Add()
DataGridViewGantt.Rows(idx).Cells(0).Value = row("TaskName")
DataGridViewGantt.Rows(idx).Cells(1).Value = row("StartDate")
DataGridViewGantt.Rows(idx).Cells(2).Value = row("EndDate")
' Add logic to color cells based on duration, etc.
Next
End Sub
End Class
7. Add/Edit/Delete Task Functionality
You can use additional forms or dialogs to add/edit tasks. Here’s a simple example for adding a task:
Private Sub btnAddTask_Click(sender As Object, e As EventArgs) Handles btnAddTask.Click
Dim projectId As Integer = ComboBoxProjects.SelectedValue
Dim taskName As String = InputBox("Enter Task Name:")
Dim startDate As Date = DateTimePickerStart.Value
Dim endDate As Date = DateTimePickerEnd.Value
Dim duration As Integer = (endDate - startDate).Days + 1
Dim query As String = $"INSERT INTO Tasks (ProjectID, TaskName, StartDate, EndDate, Duration) VALUES ({projectId}, '{taskName}', #{startDate}#, #{endDate}#, {duration})"
ExecuteNonQuery(query)
LoadTasks()
End Sub
8. Basic Gantt Chart Visualization
For a simple Gantt chart, you can use a DataGridView with colored cells representing task duration. For a more advanced chart, consider using a third-party Gantt chart control or custom drawing.
9. Next Steps
- Add more fields (resources, status, etc.).
- Implement task dependencies (Predecessor).
- Add reporting/export features.
- Migrate to SQL Server for multi-user support later.
10. Sample Project Structure
- ProjectManager.accdb
- Form1.vb (Main Form)
- DBHelper.vb (Database Helper Module)
- AddEditTaskForm.vb (Optional, for task editing)
11. Extending Functionality
Once you have this foundation, you can:
- Automate processes (e.g., auto-schedule tasks).
- Add notifications.
- Integrate with Outlook or other tools.
- Add user authentication.
Let me know which part you want to focus on next (e.g., Gantt chart, task dependencies, resource management, etc.), and I can provide more detailed code and guidance!