|
I did this:
MsgBox(getlabel(DayOfWeek.Sunday, 1))
MsgBox(getlabel(getCurrentDayOfWeek("su"), 1))
with your function and (for shortness..):
Function getlabel(ByVal day As DayOfWeek, ByVal calendarRow As Integer) As String
Select Case day 'Get a label name
Case DayOfWeek.Sunday
Select Case calendarRow
Case 1
Return "Sunday"
End Select
Case DayOfWeek.Monday
Select Case calendarRow
Case 1
Return "Monday"
End Select
Case DayOfWeek.Tuesday
Select Case calendarRow
Case 1
Return "Tuesday"
End Select
End Select
End Function
And it works...other than that...i think you will have to post your entire code...
Intelligence is almost useless for those who have nothing else!
Email: caiokf@gmail.com
|
|
|
|
|
There is no way the CInt(ClickedLabel.Name.Substring(0, 4))).Name could have changed between your calls, and have no valid data in your call using getCurrentDayOkWeek ??
Intelligence is almost useless for those who have nothing else!
Email: caiokf@gmail.com
|
|
|
|
|
|
The link doesn't work for me...send it to my email and I will take a look...caiokf@gmail.com
Regards
Intelligence is almost useless for those who have nothing else!
Email: caiokf@gmail.com
|
|
|
|
|
|
I have tried -
.SetApartmentState(ApartmentState.STA)
but when accessing the controls it is giving me the default values of .text not the value that I entered at run time. So if at design time I set .text to TEXT1 and then at run time I enter ABC, when I access the control from the thread it returns TEXT1 instead of ABC.
If I don't use
.SetApartmentState(ApartmentState.STA) then I get this error.
An error occurred creating the form. See Exception.InnerException for details. The error is: ActiveX control '35f36212-43a6-48fa-8a6a-af558abe7030' cannot be instantiated because the current thread is not in a single-threaded apartment.
This is a pain - you think it be simple to find the answer to it!
Thanks
Jim
Regards,
jim
|
|
|
|
|
Your will to use a Delegate
Public Delegate myDelegate()
Then inside the thread
Form1.TextBox1.Invoke(New myDelegate(AddressOf CheckTextBox1), New Object() {})
Then finally a sub to check the TextBox
Public Sub ChecktextBox1()
IF Form1.TextBox1.Text = "ABC..." Then
'Do something
End If
End Sub
Steve Jowett
-------------------------
Real programmers don't comment their code. If it was hard to write, it should be hard to read.
|
|
|
|
|
Sorry to be a pain here but that doesn't make sense to me.
First should it be Public Delegate Sub myDelegate() or Public Delegate Function myDelegate()? Public Delegate myDelegate() is giving me an error. I'm presuming it should be a SUB.
This is what I have for my thread
reportThread = New Thread(AddressOf ProcessReport)
With reportThread
.Priority = ThreadPriority.AboveNormal
.IsBackground = True
.Start()
End With
Inside the Sub ProcessReport I have
With frmDiscoveryII
Select Case True
Case .rbReportJourneySummary.Checked
...
Case .rbReportIdle.Checked
...
Its giving me the error at the WITH part.
As you can see I'm accessing a lot of the controls on the main form.
So where would INVOKE apply here?
Would I have to give my thread addressof a different sub to call, reportThread = New Thread(AddressOf WHATEVER) and within that set the INVOKE as following
Sub WHATEVER
frmDiscoveryII.rbReportJourneySummary.Invoke(New myDelegate(AddressOf ProcessReport), New Object() {})
frmDiscoveryII.rbReportIdle.Invoke(New myDelegate(AddressOf ProcessReport), New Object() {})
ProcessReport
END SUB
Thanks.
Regards,
jim
|
|
|
|
|
Better idea... Form2 shouldn't care anything about Form1, nor should it know of it's existance.
Create public properties on the Form2 that you fill in with the validated data from the controls on Form1. It solves the problem of breaking OOP rules, and solves your threading issues getting the data from those textbox's.
It does not, however, solve the problem of putting the data back. Like the other person said, use delegates. This code is going to have to marshal the propery call back to tue UI thread to set the text property of the controls. But, like before, you cannot just refer to them from Form2 code. For2 should only worry about the controls on Form2 and process any data it needs to. Messing with controls on Form1 is best left up to Form1 code.
|
|
|
|
|
Thanks Dave,
I have done that in the past but I believe there has to be a better way then creating public variables to hold values that are stored on a form that I should be able to access from another form. What was every wrong with form1.textbox.text = "ABS" that we use to have in previous VB verisons!
Regards,
jim
|
|
|
|
|
Because now Form2 cannot exists at all without Form1. It's called "encapsulation" in OOP, and previous versions of VB were not OOP compliant. They allowed you to get into vary bad practices, which VB.NET now, thankfully, prevents you from using since it's now completely object oriented.
|
|
|
|
|
Dave Kreskowiak wrote: previous versions of VB were not OOP compliant. They allowed you to get into vary bad practices, which VB.NET now, thankfully, prevents you from using since it's now completely object oriented.
I second that.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
Hi All,
I m getting an error when i m trying to send mail. i m using server IP address and port no. and trying to send mail from local machine which is in LAN.
After Executing an application, it is taking 1 and 1/2 minute when i m tring to send mail. after 1 n 1/2 minute it is showing a message "Operation has timed-out...
Note, On Server Side there is Proxy is set by me. And i m testing application at client side(local machine) which is in LAN.
If everyone know abt then plz help with source code.
my code is below...
Try
Dim Email As New System.Net.Mail.MailMessage( _
"dc@isol.co.in", "dharm_chand83@yahoo.com")
Email.Subject = "test subject"
Email.Body = "this is a test"
Dim mailClient As New System.Net.Mail.SmtpClient()
Dim basicAuthenticationInfo As _
New System.Net.NetworkCredential("dc@isol.co.in", mypassword")
mailClient.Host = "myserver IP Address"
mailClient.UseDefaultCredentials = False
mailClient.EnableSsl = True
mailClient.Port = my server port number
mailClient.Credentials = basicAuthenticationInfo
Email.Priority = MailPriority.High
mailClient.Send(Email)
Catch ex As Exception
MsgBox(ex.Message)
Exit Sub
End Try
MsgBox("Mail has Send")
Regards
Rohit
|
|
|
|
|
I don't use the Mail class very much at all, but the code looks OK. It looks like there is a configuration problem with your server, or how the server authentication is setup, or a proxy issue, or something else network related.
|
|
|
|
|
I am opening an application using the following code:
System.Diagnostics.Process.Start("C:\Inetpub\wwwroot\pcch2\macros\test\test.edp")
The application opens fine, and the program (test.edp) is set-up to automatically run a set of macros when opened. This runs fine as well. The trouble I am having is that I am trying to schedule this to be run multiple times a day, but to do so I need the program to be closed once the macros complete.
Is there similar code to System.Diagnostics.Process.Start that will close a program?
|
|
|
|
|
System.Diagnostics.Process.Start("C:\Inetpub\wwwroot\pcch2\macros\test\test.edp") returns as process object.
Use the kill method to close the app.
|
|
|
|
|
I tried using System.Diagnostics.Process.getcurrentprocess.kill()
but that does not seem to work.
if I am using System.Diagnostics.Process.start("c:\test.edp")
what would the kill statement be?
|
|
|
|
|
farmer wrote: System.Diagnostics.Process.start("c:\test.edp")
You're missing the returned object from the Start method. It's:
Dim newProc As Process = Process.Start("C:\test.edp")
... do something that waits for the process to complete it's work
newProc.Close()
You may want to read up on the Process class before you start throwing code around. It helps to know what's actually going on and what you're options are for controlling the new process you launch.
|
|
|
|
|
Hi,
I am using System.Diagnostics.Process.start("c:\test.edp")
I think you must have created an instance of the Process class as Start is not a static method. What you need to do to stop the process is call the Kill method on that instance.
Alan.
Oops, I see from Dave's post that there is static overload of Start.
|
|
|
|
|
Get a list of all the current running processes and close the ones you want.
Cheers!
Any suggestions, ideas, or 'constructive criticism' are always welcome.
|
|
|
|
|
hello everyone...
i have a problem with my program, everytime i selected all items on list box then export it in excel i always got this error: "Insufficient memory to continue the execution of the program".
But when i only selected one item on list box, it works properly..
thanks in advance..
jyn
|
|
|
|
|
Hummmm, tough one! I think that your computer has "Insufficient memory" to process the list of items you have selected.
How did I come to that conclusion? Who knows?
Steve Jowett
-------------------------
Real programmers don't comment their code. If it was hard to write, it should be hard to read.
|
|
|
|
|
Which one RAM you are using.
I think this is a RAM Capacity Problem..
bye
|
|
|
|
|
Hi,
I have a string and I want to make my string 'blue' through my code. Can anyone tell me how to do that.
Thanks & Regards
Mishra
|
|
|
|
|
Try the following code :
Dim g As Graphics = Me.Creategraphics 'or use other control on which you are drawing ur string.
Dim str As String = "Your String"
Dim myfont As New Font("Times New Roman", 16, FontStyle.Regular)
Dim txtsize As SizeF
txtsize = g.MeasureString(str, myfont)
Dim rect As RectangleF = New RectangleF(New PointF(0, 0), txtsize)
Dim mybrush As Brush = New LinearGradientBrush(rect, Color.Blue, Color.Blue, LinearGradientMode.ForwardDiagonal)
g.DrawString(str, myfont, mybrush, New Point(20,20))
Hope,you got what you wanted!
Gagan
|
|
|
|