Hi thanks for you answer Viorel. I've tried the example you posted however I keep getting an error with the last two statements in the if block
Dim first_draw_value = first_row.Cells("Draw")
Dim last_draw_value = last_row.Cells("Draw")
I switch out ("Draw") with all the different column names including one called ("Game") however the same error keeps popping up.
Message=Column named Game cannot be found.
System.ArgumentException
HResult=0x80070057
Message=Column named Game cannot be found.
Parameter name: columnName
Source=System.Windows.Forms
StackTrace:
at System.Windows.Forms.DataGridViewCellCollection.get_Item(String columnName)
at PowerBallDB.Form1.Button2_Click(Object sender, EventArgs e) in C:\Users\user\source\repos\PowerBallDB\PowerBallDB\Form1.vb:line 102
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at PowerBallDB.My.MyApplication.Main(String[] Args) in :line 83
This exception was originally thrown at this call stack:
[External Code]
PowerBallDB.Form1.Button2_Click(Object, System.EventArgs) in Form1.vb
[External Code]