|
This may be simple but I need to display a status message in a label while creating a zip folder. For example, while the folder is being created I want the label to display please wait and when the folder is done I want the label to display finish.
jds1207
|
|
|
|
|
label1.text = "Please Wait..."
'the line below is necessary because the zip is an intesive operation and the label1 may never display the text(or paint itself)
application.doevents
call zipfile()
label1.text=string.empty 'or visible=false
helpful or more to it?
|
|
|
|
|
I am a little confused. Here is the code where I call the functions under the button click:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim dirname As String = DateTime.Now.ToString("MM_dd_yyyy_hh_mm_ss") & "\"
CreateBackUpFolder(GlobalVariables.backupfolder, dirname)
CreateZip(GlobalVariables.sourcefolder, GlobalVariables.backupfolder & dirname & GlobalVariables.backupfile)
When CreateBackupFolder & CreateZip are in progress I want the label to display please wait and when done I want the label to display finish.
I hope I explained this clear enough for you.
jds1207
|
|
|
|
|
So, change your label before you call your Create.... thingy's.
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim dirname As String = DateTime.Now.ToString("MM_dd_yyyy_hh_mm_ss") & "\"
StatusLabel.Text = "Please wait..."
Application.DoEvents()
CreateBackUpFolder(GlobalVariables.backupfolder, dirname)
CreateZip(GlobalVariables.sourcefolder, GlobalVariables.backupfolder & dirname & GlobalVariables.backupfile)
.
.
.
It would be better if you made a method to change the status label so you can call it from anywhere in your form code though...
Private Sub UpdateStatusUI(ByVal message As String)
StatusLabel.Text = message
Application.DoEvents()
End Sub
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Thank you! This worked fine.
|
|
|
|
|
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim dirname As String = DateTime.Now.ToString("MM_dd_yyyy_hh_mm_ss") & "\"
label1.text = "Please Wait..." '<<<<<<<<<<<<
Application.doevents '<<<<<<<<<<<<
CreateBackUpFolder(GlobalVariables.backupfolder, dirname)
CreateZip(GlobalVariables.sourcefolder, GlobalVariables.backupfolder & dirname & GlobalVariables.backupfile)
label1.text = "Finished" '<<<<<<<<<<<<
End Sub
|
|
|
|
|
Thank you also! Your code is pretty much the same.
|
|
|
|
|
Hi,
Can we use a vb6 file vb.net project. If yes then how it can be done.
Please help me.
Thanks & Regards
Mishra
|
|
|
|
|
There are many different types of files - which one do you mean? Source? Compiled dll? What?
|
|
|
|
|
Although there a lot of similarities between VB6 and VB.NET, VB6 code usually has to be re-written to work properly in VB.NET. For instance, a Long value in VB6 is 32-bit integer whereas it's a 64-bit integer in VB.NET. The equivilent data type to a VB6 Long would be an Integer in VB.NET.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
anyone know about this error message?
System.InvalidCastException:Cast from type 'DBNull'to type 'Date'is not valid
at Microsoft.VisualBasic.CompilerServices.DateType.FromObject(Object Value)
may i know the way to solve it.....
|
|
|
|
|
You're trying to convert a Null value into data type Date which is not allowed. Post your code and either I or someone else will show you where you went wrong & how to fix it.
|
|
|
|
|
'let's say your field is dsRow("DateField")
Dim dtVal as date = cdate(dsRow("DateField")) ' error because of null value
**instead do this**
dim dtVal as date
If isdbnull(dsRow("DateField")) Then
'do notta
Else
dtVal = cdate(dsRow("DateField"))
end if
|
|
|
|
|
Thank you!;)
finally the error solve d...thanks
|
|
|
|
|
Can i take the substraction between 2 date.
Eg: current date is : 2006-10-24
Also, previous date is : 2006-10-18
Them, can i take the current date minus the previous date, so i can take the result is 7days?
Here is the Code:
Dim ChkDate As Date
ChkDate = ChkDate.Now
ChkDate = ChkDate.ToString("yyyy-MM-dd")
'i take the date from dateReader(SQL)
sqlPDate = dtrCheckQty("PurcahseDate").ToString
sqlPDate = sqlPDate.ToString("yyyy-MM-dd")
Dim DiffDate As Integer =Convert.ToInt32(ChkDate.ToString) - Convert.ToInt32(sqlPDate.ToString)
If (diffDate > 5) Then
....
....
End if
How can i solve the problem?
Hope anyone can help me in this problem.
Thanks alot...
-- modified at 16:01 Monday 23rd October, 2006
|
|
|
|
|
You are converting back and forth between strings and dates so many times, that it's a wonder if you would get anything reasonable at all. The part of your code that is compilable actually does this:
Dim ChkDate As Date<br />
ChkDate = ChkDate.Now<br />
ChkDate = Conver.ToDateTime(ChkDate.ToString("yyyy-MM-dd"))<br />
sqlPDate = Convert.ToDateTime(dtrCheckQty("PurcahseDate").ToString)<br />
sqlPDate = Convert.ToDateTime(sqlPDate.ToString("yyyy-MM-dd"))
From what I can see, you try to convert the dates to strings, which is immediately reversed as they are converted back when you store them in the same variable again. Just as well, if you would have succeeded in converting them to strings, you would not be able to get the time difference anyway, as you can't subtract strings.
Then you subtract the dates, which works just fine, but it gives a result of the type TimeSpan, that you try to store in an integer variable. This is of course not possible.
Stop trying to convert the dates to strings, store the result of the subtraction in a TimeSpan variable, and get the time difference in days by using the TotalDays property.
---
b { font-weight: normal; }
|
|
|
|
|
Newbie_dydy85 wrote: sqlPDate = dtrCheckQty("PurcahseDate").ToString
dtrCheckQty("PurcahseDate") is the date to be checked then:
Dim chkDate As Date = CDate(dtrCheckQty("PurcahseDate"))<br />
If DateDiff(DateInterval.Day, Date.Now, chkDate) = -7 Then<br />
' the date within the varaible chkDate is 7 days old<br />
........<br />
........<br />
End If
Hope this helps.
|
|
|
|
|
I have created a simple user control consisting of a label and a text box (is a similar dialog already available?). I would like to include for example a public property in the 'Appearance' category and a 'Description'.
In order to add this meta data within the cbf, I remember I have to write for example
<Category("Appearance)> _
Public Property BackColor
...
implemenentation
...
End Property
Do I have to import some namespace or add something so that I can view, for example, <Appearance, <Description, etc...?
I hope I was clear.
Code:
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class LabelAndTextBox
Inherits System.Windows.Forms.UserControl
'UserControl overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.labelName = New System.Windows.Forms.Label
Me.Info = New System.Windows.Forms.TextBox
Me.SuspendLayout()
'
'labelName
'
Me.labelName.AutoSize = True
Me.labelName.BackColor = System.Drawing.Color.LightSteelBlue
Me.labelName.Location = New System.Drawing.Point(3, 4)
Me.labelName.Name = "labelName"
Me.labelName.Size = New System.Drawing.Size(0, 13)
Me.labelName.TabIndex = 0
'
'Info
'
Me.Info.BackColor = System.Drawing.Color.LightSteelBlue
Me.Info.Location = New System.Drawing.Point(91, 1)
Me.Info.Name = "Info"
Me.Info.ReadOnly = True
Me.Info.Size = New System.Drawing.Size(111, 20)
Me.Info.TabIndex = 1
'
'LabelAndTextBox
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.BackColor = System.Drawing.Color.LightSteelBlue
Me.Controls.Add(Me.Info)
Me.Controls.Add(Me.labelName)
Me.Name = "LabelAndTextBox"
Me.Size = New System.Drawing.Size(202, 23)
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents labelName As System.Windows.Forms.Label
Friend WithEvents Info As System.Windows.Forms.TextBox
Public Property labelText() As String
Get
Return labelName.Text
End Get
Set(ByVal value As String)
labelName.Text = value
End Set
End Property
Public Property textBoxText() As String
Get
Return Info.Text
End Get
Set(ByVal value As String)
Info.Text = value
End Set
End Property
Public Overrides Property BackColor() As System.Drawing.Color
Get
Return MyBase.BackColor
End Get
Set(ByVal value As System.Drawing.Color)
Info.BackColor = value
labelName.BackColor = value
End Set
End Property
Jon
|
|
|
|
|
I'm not sure if this is the answer, but I have some documentation that covers something similar. I think you're on the right track, it's just the syntax that's wrong.
The doco I have uses this:
<CategoryAttribute("Appearance")>
There's a heap more options too: DescriptionAttribute, BrowsableAttribute, ReadOnlyAttribute, DefaultValueAttribute, and DefaultPropertyAttribute
As far as I'm aware, there's nothing that needs to be imported.
Have a look at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/usingpropgrid.asp
Hope that helps a bit.
|
|
|
|
|
Hello everybody,
I try to use this "try catch" block :
<br />
Function DateConvert(ByVal strDate As String) As String<br />
Dim jj, mm, aa As String<br />
Dim buf() As String<br />
<br />
Try<br />
buf = Split(strDate, "/")<br />
jj = buf(0)<br />
mm = buf(1)<br />
aa = buf(2)<br />
Catch ex As Exception<br />
Throw ex<br />
End Try<br />
<br />
If (System.Web.Configuration.WebConfigurationManager.AppSettings("OS") = "US") Then<br />
DateConvert = mm & "/" & jj & "/" & aa<br />
Else<br />
DateConvert = jj & "/" & mm & "/" & aa<br />
End If<br />
<br />
End Function<br />
When I pass a string with a bad date format like "02/2006" or "" instead of "23/10/2006"
I get this error : "Index was outside the bounds of the array."
The "try catch" block must catch this type of error but not there... why ?
Please, my code doesn't look bad but I don't find where I'm wrong...
PS1 : I also try with an IndexOutOfRangeException exception with the same result !!
PS2 : I use the Framework 2.0...
|
|
|
|
|
First off, it looks to me like you are just catch the exception and then rethrowing it so I am not sure what you are expecting to happen there.
Second, IMHO it would be better to validate the string a bit and even check to see if after the split there are enough array parts before trying to access them instead of just throwing an exception there.
|
|
|
|
|
Thanks for your answer, I'm OK that the way I try to use is not really "beautiful", but what I want to know is why, when an exception occures, this Exception is not treated by the catch block ?
I just want to throw it to the call function and treat this exception in the call function.
|
|
|
|
|
It being treated by the catch block. The only thing you're doing is re-throwing the same exception, which isn't being handled by the code that called the code snippet you posted.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
the reason why you are getting "Index was outside the bounds of the array." is because you have hardcoded your code to assume there will always be 3 pieces of the date present.
jj = buf(0)
mm = buf(1)
'the below will not be available when you pass in 02/2006...there is no second slash present to make the array go up to an upperbound of 2.
aa = buf(2)
|
|
|
|
|
Hi, I would like to know, if anybody of you experts got a code that can deconvert a BASE64 encoded string.
I dont want the normal function with the normal lookuptable, but i would like to have the ability to change the lookup-table.
For example the normal is ABCDEFGHIJKLMNOPQRSTUVWX......
And i maybe want to change that start into ABD8291ADJqmJDmqHDMQA.....
I've alrady got a Class Module that can do that in Visual Basic 6, and i tried to convert it into VB.NET code, but i always get the error at the STRCONV(strEncoded, vbUnicode) or something. But if anybody out there got a link for a source code i would be happy.
Greetings!
|
|
|
|