|
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!
|
|
|
|
|
Use the ToCharArray method to get a char array from the string, so that you can translate each character to/from the corresponding character in your own table. Then use the Convert.FromBase64CharArray method.
---
b { font-weight: normal; }
|
|
|
|
|
Sounds cool.
But what if i want to change the LOOKUP-TABLE?
Can you give an example of that??
|
|
|
|
|
You can't change the lookup table. Translate the characters before you decode the string.
---
b { font-weight: normal; }
|
|
|
|
|
I need to know how to create a progress bar in vb.net 2005. I want the progres bar to show progress when zip file is being created.
jds1207
|
|
|
|
|
Your question is really general but I’ve post a code snippet in my blog here at CP that is written in VB.NET and uses a progress bar to measure the progress of a download from a website.Web Client Download w/ProgressBar[^]
|
|
|
|
|
The ProgressBar only shows progress when you tell it there is some. Just putting a ProgressBar on your form won't do anything unless your app is zipping the files and your keeping track of how many files you have yet to compress into the archive.
So, are you compressing each file yourself, or are you doing this some other way?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
How do you turn the field view in release 9 of crystal reports. There is a way using the ctrl key with another key, but for the live of me, I can't remember.
Thanks
silver-gray
|
|
|
|
|
Hi,
I am writing an addin that adds a popup menu to the Code Window command bar. The menu structure is as follows:
MyCommands-->Order Namespaces
----------------Regions-->Add to New Region
--------------------------Add to Existing Region
How can I disable MyCommands if the active document is not a VB file. I know that I can disable Command objects in the QueryStatus method but this method is never fired. I use the code below.
<br />
Private cmdBar As CommandBar<br />
Private myCommandsPopup As CommandBarPopup<br />
Private regionsPopup As CommandBarPopup<br />
Private WithEvents mnuOrderNamespaces As CommandBarButton<br />
Private WithEvents mnuAddToNewRegion As CommandBarButton<br />
Private WithEvents mnuAddToExistingRegion As CommandBarButton<br />
<br />
cmdBar = CType(CType(_applicationObject.CommandBars, CommandBars)("Code Window"), CommandBar)<br />
<br />
myCommandsPopup = CType(cmdBar.Controls.Add(MsoControlType.msoControlPopup, nullParam, nullParam, 1, nullParam), CommandBarPopup)<br />
myCommandsPopup.Caption = "MyCommands"<br />
<br />
mnuOrderNamespaces = CType(myCommandsPopup.Controls.Add(MsoControlType.msoControlButton, nullParam, nullParam, 1, nullParam), CommandBarButton)<br />
mnuOrderNamespaces.Caption = "Order Namespaces"<br />
<br />
regionsPopup = CType(myCommandsPopup.Controls.Add(MsoControlType.msoControlPopup), CommandBarPopup)<br />
regionsPopup.Caption = "Regions"<br />
<br />
mnuAddToNewRegion = CType(regionsPopup.Controls.Add(MsoControlType.msoControlButton), CommandBarButton)<br />
mnuAddToNewRegion.Caption = "Add to New Region"<br />
mnuAddToNewRegion.FaceId = 1554<br />
<br />
mnuAddToExistingRegion = CType(regionsPopup.Controls.Add(MsoControlType.msoControlButton), CommandBarButton)<br />
mnuAddToExistingRegion.Caption = "Add to Existing Region"<br />
mnuAddToExistingRegion.FaceId = 1555<br />
Any suggestions?
Thanks very much,
dlarkin77
-- modified at 10:25 Monday 23rd October, 2006
|
|
|
|
|
I have been using vb6 and vb.net(2003) to date I have recieved a trial
version of VS2005 and would like to try and create an Intranet application.
I am basicly looking to generate a secure menu system running against our
2005 SQL Servers.
I may be trying to run before i can walk, but thats just me. Id like to
have a logon tested against a SQL table. on a sucessfull logon go to a 'page'
that displays a datagrid form a different table. I would also need to know
how i can stop direct access to the second page bypassing the logon page, and
also preventing the use of the back button from the second page to the logon
page. Its a lot to ask, but i think from this information it will give me a
good base to learn from
if anybody can point me in the right direction, i will be very greatfull
I really do need help..... all this computer stuff is way over my head !!
|
|
|
|
|
Pete Newman wrote: Id like to
have a logon tested against a SQL table.
You can still use methods from VS2003 to perform a logon in VS2005. Or do you want to make use of the new login controls[^]?
Pete Newman wrote: on a sucessfull logon go to a 'page'
that displays a datagrid form a different table. I would also need to know
how i can stop direct access to the second page bypassing the logon page, and
also preventing the use of the back button from the second page to the logon
page.
I'd suggest creating the aspx page with the datagrid that's bound to your datasource and control access to that page using roles in the "User" object, e.g.
If User.IsInRole("Admin") Then
Response.Redirect("datagridpage.aspx")
End If
Not sure how or why you want to disable the back button to the logon page. You could add code in the PageLoad event of the second page to conditionally check whether or not the current user has viewing permission for the page - if they don't, redirect them to the logon form. This would really only apply if/when they typed in the url for that page directly (otherwise it would already have been checked through your logon procedure).
Does that help at all?
|
|
|
|
|
kulazfuk,
Thanks for the response.
the second part of your reply is very usefull thank you , however its the first part im still stuck on. I'll give a little background on what im atempting to do.. maybe you can suggest the best route
we have an old VB6 application which resides on each users work stations and access the main SQL server .. im trying to create a simple trial 'Intra-net' project to see if the vb6 application can be replaced.
Currently in the vb6 app, the user logs completes a logon name and password which is queired against an Operators table in the main database on the main server. im trying to replicate the same sort of logon on .. Idealy id love to use the build in login controls but , honestly dont have a clue how to
this is my first attempt at an 'intra-net' so i need all the help i can get. I have looked for tutorials with no sucess
I really do need help..... all this computer stuff is way over my head !!
|
|
|
|
|
Hi Pete,
If you're not too worried by a deadline for this I would suggest you write your own logic for login operations before you start making use of the built in controls, that way you'll have a better understanding of why they behave as they do. Build a few sample applications to test it out, the best way to learn is to try.
Click on the link I gave you in the previous post for an overview of the new ASP.NET login controls, from there onwards you'll find many links regarding web site security, membership and more.
Also, do you have any experience in developing? Although I know you'd rather have this as a web application to run off your intranet, if you're bound to a deadline perhaps you could look at making it a desktop app? You may find that easier.
|
|
|
|
|
Hi Kulazuk,
Thanks again for the pointer. Im off to have a play ..... If i get stuck i know where to come back to
PS the link is very usefull
I really do need help..... all this computer stuff is way over my head !!
|
|
|
|