Saturday, May 14, 2011

DotNet Factory useful code

'##################################################################
'#          Action Name     :
'#          Creator              : Baba Fakruddin Dudekula
'#          Creation Date    :
'#          Description        : Dot net factory sample code
'#          Reason             :
'#          I/P Parameter    :
'#          O/p Parameter   :
''##################################################################
'#          Modification Id       :
'#          Modification Author : Baba Fakruddin Dudekula
'#          Modified Date        : 16-Oct-2011
'#          Modification Details: Output from the Button click
''##################################################################
Option Explicit

Dim MyForm, txt_Date, txt_EntryTime, txt_Task, txt_Status, txt_Meetings, txt_MeetingsDuration, txt_Activity, txt_ActivityDuration, txt_ExitTime, MyButton, MyButton1,_
lbl_Date, lbl_EntryTime, lbl_Task, lbl_Status, lbl_Meetings, lbl_MeetingsDuration, lbl_Activity, lbl_ExitTime, sysdate, var , dResult, Pos, lbl_ActivityDuration, x, y,_
FormattedDate, MyText

'________________________________________________  Status Code   ________________________________________________________
Set MyForm = DotNetFactory.CreateInstance("System.Windows.Forms.Form", "System.Windows.Forms")

' Creating an objects for the Text fields
Set txt_Date = DotNetFactory.CreateInstance("System.Windows.Forms.TextBox", "System.Windows.Forms")
Set txt_EntryTime = DotNetFactory.CreateInstance("System.Windows.Forms.TextBox", "System.Windows.Forms")
Set txt_Task = DotNetFactory.CreateInstance("System.Windows.Forms.TextBox", "System.Windows.Forms")
Set txt_Status = DotNetFactory.CreateInstance("System.Windows.Forms.TextBox", "System.Windows.Forms")
Set txt_Meetings = DotNetFactory.CreateInstance("System.Windows.Forms.TextBox", "System.Windows.Forms")
Set txt_MeetingsDuration = DotNetFactory.CreateInstance("System.Windows.Forms.TextBox", "System.Windows.Forms")
Set txt_Activity = DotNetFactory.CreateInstance("System.Windows.Forms.TextBox", "System.Windows.Forms")
Set txt_ActivityDuration = DotNetFactory.CreateInstance("System.Windows.Forms.TextBox", "System.Windows.Forms")
Set txt_ExitTime = DotNetFactory.CreateInstance("System.Windows.Forms.TextBox", "System.Windows.Forms")

' Creating an objects for the buttons
Set MyButton = DotNetFactory.CreateInstance("System.Windows.Forms.Button", "System.Windows.Forms")
Set MyButton1 = DotNetFactory.CreateInstance("System.Windows.Forms.Button", "System.Windows.Forms")

' Creating an object for the labels to edit boxes
Set lbl_Date = DotNetFactory.CreateInstance("System.Windows.Forms.Label","System.Windows.Forms")
Set lbl_EntryTime = DotNetFactory.CreateInstance("System.Windows.Forms.Label","System.Windows.Forms")
Set lbl_Task = DotNetFactory.CreateInstance("System.Windows.Forms.Label","System.Windows.Forms")
Set lbl_Status = DotNetFactory.CreateInstance("System.Windows.Forms.Label","System.Windows.Forms")
Set lbl_Meetings = DotNetFactory.CreateInstance("System.Windows.Forms.Label","System.Windows.Forms")
Set lbl_MeetingsDuration = DotNetFactory.CreateInstance("System.Windows.Forms.Label","System.Windows.Forms")
Set lbl_Activity= DotNetFactory.CreateInstance("System.Windows.Forms.Label","System.Windows.Forms")
Set lbl_ActivityDuration= DotNetFactory.CreateInstance("System.Windows.Forms.Label","System.Windows.Forms")
Set lbl_ExitTime= DotNetFactory.CreateInstance("System.Windows.Forms.Label","System.Windows.Forms")
Set sysdate = dotnetfactory.CreateInstance("System.DateTime")
var = sysdate.Now

''* Creating an object for the Result after clicking Button
Set dResult = DotNetFactory.CreateInstance("System.Windows.Forms.DialogResult", "System.Windows.Forms")

' Creating an object for the Drawing point
Set Pos = DotNetFactory.CreateInstance("System.Drawing.Point","System.Drawing",x,y)

MyForm.Text = "My Daily Status Updates"
MyForm.Maximizebox = True
MyForm.Minimizebox = True
MyForm.Width = 700
MyForm.Height =600
'MyForm.Location.X = 100
'MyForm.Location.Y = 200

'__________________________________     Date:  __________________________________

' Adding Label in window
Pos.X=110
Pos.Y=80
lbl_Date.Location = Pos
lbl_Date.Text="Date: "
MyForm.Controls.Add lbl_Date

' Adding Text field (Date) in Window
Pos.X = 380
Pos.Y = 80
txt_Date.Location = Pos
txt_Date.Text = var
txt_Date.Width = 200
MyForm.Controls.Add txt_Date

'__________________________________     Task Started Time:  _______________________________
' Adding Label in window
Pos.X=110
Pos.Y=120
lbl_EntryTime.Location = Pos
lbl_EntryTime.Text="Task Started Time: "
MyForm.Controls.Add lbl_EntryTime

' Adding Text field (Entry Time) in Window
Pos.X = 380
Pos.Y = 120
txt_EntryTime.Location = Pos
txt_EntryTime.Text = ""
txt_EntryTime.Width = 200
MyForm.Controls.Add txt_EntryTime

'__________________________________     Task :  _______________________________
' Adding Label in window
Pos.X=110
Pos.Y=160
lbl_Task.Location = Pos
lbl_Task.Text="Task : "
MyForm.Controls.Add lbl_Task

' Adding Text field (Entry Time) in Window
Pos.X = 380
Pos.Y = 160
txt_Task.Location = Pos
txt_Task.Text = ""
txt_Task.Width = 200
MyForm.Controls.Add txt_Task

'__________________________________    Status :  _______________________________
' Adding Label in window
Pos.X=110
Pos.Y=200
lbl_Status.Location = Pos
lbl_Status.Text="Status : "
MyForm.Controls.Add lbl_Status

' Adding Text field (Entry Time) in Window
Pos.X = 380
Pos.Y = 200
txt_Status.Location = Pos
txt_Status.Text = ""
txt_Status.Width = 200
MyForm.Controls.Add txt_Status

'__________________________________    Meetings:  _______________________________

' Adding Label in window
Pos.X=110
Pos.Y= 240
lbl_Meetings.Location = Pos
lbl_Meetings.Text="No. of Meetings: "
MyForm.Controls.Add lbl_Meetings

' Adding Text field (Entry Time) in Window
Pos.X = 380
Pos.Y = 240
txt_Meetings.Location = Pos
txt_Meetings.Text = ""
txt_Meetings.Width = 200
MyForm.Controls.Add txt_Meetings

'__________________________________     Meeting duration:  _______________________________

' Adding Label in window
Pos.X=110
Pos.Y=280
lbl_MeetingsDuration.Location = Pos
lbl_MeetingsDuration.Text="Meeting Duration in a day: "
lbl_MeetingsDuration.Width = 200
MyForm.Controls.Add lbl_MeetingsDuration

' Adding Text field (Entry Time) in Window
Pos.X = 380
Pos.Y = 280
txt_MeetingsDuration.Location = Pos
txt_MeetingsDuration.Text = ""
txt_MeetingsDuration.Width = 200
MyForm.Controls.Add txt_MeetingsDuration

'__________________________________     Activity:  _______________________________

' Adding Label in window
Pos.X=110
Pos.Y=320
lbl_Activity.Location = Pos
lbl_Activity.Text="Activity: "
MyForm.Controls.Add lbl_Activity

' Adding Text field (Entry Time) in Window
Pos.X = 380
Pos.Y = 320
txt_Activity.Location = Pos
txt_Activity.Text = ""
txt_Activity.Width = 200
MyForm.Controls.Add txt_Activity

'__________________________________     Activity Duration:  _______________________________

' Adding Label in window
Pos.X=110
Pos.Y=360
lbl_ActivityDuration.Location = Pos
lbl_ActivityDuration.Text="Activity Duration: "
MyForm.Controls.Add lbl_ActivityDuration

' Adding Text field (Entry Time) in Window
Pos.X = 380
Pos.Y = 360
txt_ActivityDuration.Location = Pos
txt_ActivityDuration.Text = ""
txt_ActivityDuration.Width = 200
MyForm.Controls.Add txt_ActivityDuration

'__________________________________     Exit Time:  _________________________________

' Adding Label in window
Pos.X=110
Pos.Y=400
lbl_ExitTime.Location = Pos
lbl_ExitTime.Text="Exit Time: "
MyForm.Controls.Add lbl_ExitTime

' Adding Text field (Entry Time) in Window
Pos.X = 380
Pos.Y = 400
txt_ExitTime.Location = Pos
txt_ExitTime.Text = ""
txt_ExitTime.Width = 200
MyForm.Controls.Add txt_ExitTime

Pos.X = 240
Pos.Y = 490
MyButton.Text = "OK"
MyButton.Height = 30
MyButton.Width = 80
MyButton.Location = Pos
MyButton.DialogResult = dResult.OK

Pos.X = 400
Pos.Y = 490
MyButton1.Text = "Close"
MyButton1.Height = 30
MyButton1.Width = 80
MyButton1.Location = Pos
MyButton1.DialogResult = dResult.Cancel

MyForm.Controls.Add MyButton
MyForm.Controls.Add MyButton1

MyForm.CancelButton = MyButton
MyForm.CancelButton = MyButton1

'MyForm.Show
MyForm.ShowDialog

If MyForm.DialogResult = dResult.OK Then
  msgbox "OK Button Pressed"
else
  msgbox "Close Button Pressed"
End If

'Var = txt_Date.Text
'Msgbox Var

Set MyText = Nothing
Set MyForm = Nothing
Set txt_Date = Nothing
Set txt_EntryTime = Nothing
Set txt_Task = Nothing
Set txt_Status = Nothing
Set txt_Meetings = Nothing
Set txt_MeetingsDuration = Nothing
Set txt_Activity = Nothing
Set txt_ActivityDuration = Nothing
Set txt_ExitTime = Nothing

Set MyButton = Nothing
Set MyButton1 = Nothing

Set lbl_Date = Nothing
Set lbl_EntryTime = Nothing
Set lbl_Task = Nothing
Set lbl_Status = Nothing
Set lbl_Meetings = Nothing
Set lbl_MeetingsDuration = Nothing
Set lbl_Activity = Nothing
Set lbl_ActivityDuration = Nothing
Set lbl_ExitTime = Nothing
Set sysdate = Nothing
Set dResult = Nothing
Set Pos = Nothing



'
'
'msgbox date
'msgbox now
'
'
'Dim sysdate, odate
'Set sysdate = dotnetfactory.CreateInstance("System.DateTime")
''Set odate =sysdate.parse("Fri, 9 Oct 2009")
'Set odate = sysdate.Now
'msgbox odate
'Formatteddate = odate.day&"/"& odate.Month & "/"& odate.year
'msgbox Formatteddate
'Set sysdate= nothing
'Set odate = nothing

1 comment:

Parke Kuntz said...

Have you played with hashtable and dictionaryEntry? I have been unable to get dictionaryEntry to use de and get the keys. Any help would be appreciated.

There was an error in this gadget