Solved

Vb Grid

Posted on 2014-09-28
3
187 Views
Last Modified: 2014-10-01
Hi  

I have a Grid that shows selected Dates in Month is colour and any Staff Leave application in different colour
If the user clicks on a leave the program ask if the user wants to delete the leave Yes No

Dim Empno as String = Selected Employee Number from Table
Dim SDate as Sting = Start Date From Table
Dim EDate as String = End Date from Table

if Showmessage("delete Employee " & Empno & " from date " & Sdate " to Date " & eDate ) = Yes then
  Delete from Table
End if
  changeLeaveDate()
end if

how do I get the Empno, SDate and EDate to be seen in the ChangeLeave form
0
Comment
Question by:Kevinfeening
  • 2
3 Comments
 
LVL 20

Expert Comment

by:ElrondCT
ID: 40349293
If I understand you correctly, you want to put a date control (DateTimePicker?) into a DataGrid. I'm aware of three options:

1) Put a regular DateTimePicker into a DataGrid. One example of how to do this (and other types of controls) is at http://www.codeproject.com/Articles/9558/How-to-add-selection-controls-to-your-DataGrid

2) Buy a commercial control designed for this. I've liked Rustemsoft's DataGridColumns .NET assembly (www.rustemsoft.com).

3) Create your own class, using Inherits DataGridColumnStyle. MS actually provides an example of this on the DataGridColumnStyle class documentation page: http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridcolumnstyle%28v=vs.110%29.aspx?cs-save-lang=1&cs-lang=vb#code-snippet-2 shows .NET v4.5, but click on Other Versions if needed.

If I've misunderstood your need, my apologies. Perhaps if you describe a bit more about how your Grid is set up and how you're wanting to make changes, I can provide better assistance.
0
 

Author Comment

by:Kevinfeening
ID: 40349306
Hi ElrondCT

Thanks No I don't need a timepicker

I worked out how to send the Variable values since email

The first Part of the code
if Showmessage("delete Employee " & Empno & " from date " & Sdate " to Date " & eDate ) = Yes then
   Delete from Table

Deletes the record correctly

I want to send the Empno SDate and eDate to a new form with 3 labels and  a Date picker already on it
if the user clicks NO to Delete Employee then using

dim changeDate as New changeLeaveDate()
changeDate.SendVariables(me.Empno, Me.SDate, Me.eDate
changeLeaveDate.show()

in the changeLeaveDate form I have

Public Sub SendVariables(byVal Empno, ByVal SDate, ByVal eDate)
empno, sDate and eDate all have the correct values
end sub

How do I use these variables in the
Public Sub changeLeaveDate_Load(ByVal Sender as System.Object, byVal e As System.EventArgs)

' Set the Label text
label1.text = Empno
label2.text = sDate
label3.text = "End Date"
datetimepicker1.text = eDate

End Sub
0
 
LVL 20

Accepted Solution

by:
ElrondCT earned 500 total points
ID: 40351540
You're doing it in the wrong order. Load happens when the form is first instantiated, so it's already happened before you use your SendVariables method. You can set each of the controls in SendVariables:
Public Sub SendVariables(byVal Empno, ByVal SDate, ByVal eDate)
' Set the Label text
label1.text = Empno
label2.text = sDate
datetimepicker1.text = eDate
end sub

Open in new window

You can also set the values directly, from the parent form, assuming the controls are declared Friend or Public (Friend is the default):
dim changeDate as New changeLeaveDate()
changeDate.label1.text = Empno
changeDate.label2.text = sDate
changeDate.datetimepicker1.text = eDate
changeDate.show()          ' Note the corrected name; show the instance, not the type

Open in new window

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question