|
I googled "vb.net get time"
Here is the what I found on the third line:
<br />
Dim Now AsDateTime = DateTime.Now<br />
MessageBox.Show(Now)<br />
You always pass failure on the way to success.
|
|
|
|
|
|
Hm... I don't want to appear impolite but how about googling it?
Oh - and you're welcome
You always pass failure on the way to success.
|
|
|
|
|
|
Then ignore the date part.
|
|
|
|
|
Hi,
Is it possible to print a Windows Form? I have a form that needs to be printed. I am not dealing with data source, but values objects. I am using VB .NET 2005. If a form cannot be printed, then what best approach is possible to give some results to print. Their is no Data Source. Just display values from objects, prepare a descent form and print it.
Any help is highly appreciated.
Thanks
Trupti
Thanks
Terry
|
|
|
|
|
|
Hello Trupti,
Printing in Windows Forms consists primarily of using the PrintDocument Component (Windows Forms) component to enable the user to print, and the PrintPreviewDialog Control (Windows Forms) control, PrintDialog Component (Windows Forms) and PageSetupDialog Component (Windows Forms) components to provide a familiar graphical interface to users accustomed to the Windows operating system.
Typically, you create a new instance of the PrintDocument component, set the properties that describe what to print using the PrinterSettings and PageSettings classes, and call the Print method to actually print the document.
During the course of printing from a Windows-based application, the PrintDocument component will show an abort print dialog box to alert users to the fact that printing is occurring and to allow the print job to be canceled.
The foundation of printing in Windows Forms is the PrintDocument component—more specifically, the PrintPage event. By writing code to handle the PrintPage event, you can specify what to print and how to print it.
To create a print job:
1. Add a PrintDocument component to your form.
2. Write code to handle the PrintPage event.
You will have to code your own printing logic. Additionally, you will have to specify the material to be printed.
In the following code example, a sample graphic in the shape of a red rectangle is created in the PrintPage event handler to act as material to be printed.
Visual Basic Copy Code
Private Sub PrintDocument1_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
e.Graphics.FillRectangle(Brushes.Red, New Rectangle(500, 500, 500, 500))
End Sub
C# Copy Code
private void printDocument1_PrintPage(object sender,
System.Drawing.Printing.PrintPageEventArgs e)
{
e.Graphics.FillRectangle(Brushes.Red,
new Rectangle(500, 500, 500, 500));
}
J# Copy Code
private void printDocument1_PrintPage(Object sender,
System.Drawing.Printing.PrintPageEventArgs e)
{
e.get_Graphics().FillRectangle(Brushes.get_Red(),
new Rectangle(500, 500, 500, 500));
}
C++ Copy Code
private:
void printDocument1_PrintPage(System::Object ^ sender,
System::Drawing::Printing::PrintPageEventArgs ^ e)
{
e->Graphics->FillRectangle(Brushes::Red,
Rectangle(500, 500, 500, 500));
}
(Visual C#, Visual J# and Visual C++) Place the following code in the form's constructor to register the event handler.
C# Copy Code
this.printDocument1.PrintPage += new
System.Drawing.Printing.PrintPageEventHandler
(this.printDocument1_PrintPage);
J# Copy Code
this.printDocument1.add_PrintPage(new
System.Drawing.Printing.PrintPageEventHandler
(this.printDocument1_PrintPage));
C++ Copy Code
printDocument1->PrintPage += gcnew
System::Drawing::Printing::PrintPageEventHandler
(this, &Form1::printDocument1_PrintPage);
You may also want to write code for the BeginPrint and EndPrint events, perhaps including an integer representing the total number of pages to print that is decremented as each page prints.
Note
You can add a PrintDialog component to your form to provide a clean and efficient user interface (UI) to your users. Setting the Document property of the PrintDialog component enables you to set properties related to the print document you are working with on your form. For more information about the PrintDialog component, see PrintDialog Component (Windows Forms).
I hope this helps.
Have a nice day.
Regards,
James Smith
James Smith
www.componentone.com
|
|
|
|
|
|
Hello,
I want to show all figures in form of 2 or 1 decimal places respectively. I have a form, where I have several text boxes. I use NumberFormatInfo to set the decimal places accordingly.
<br />
Private nfi As New System.Globalization.NumberFormatInfo<br />
nfi.NumberDecimalDigits = 2<br />
<br />
'NOT WORKING. SOWS A PURE DOUBLE NUMBER<br />
s = absentAmt.ToString(nfi)<br />
absentAmt = Double.Parse(s.Trim())<br />
<br />
' Calculate UFI WORKING PERFECTLY FINE<br />
uif = ((Me.salary * 1) / 100)<br />
Me.uifTB.Text = uif.ToString(nfi)<br />
uif = Double.Parse(Me.uifTB.Text().Trim())<br />
<br />
' AMOUNT DEDUCTED 'NOT WORKING. SOWS A PURE DOUBLE NUMBER<br />
Me.totalDeduct = (Me.loanRepay + Me.absentAmt + uif)<br />
Me.amtDedTB.Text = Me.totalDeduct.ToString(nfi)<br />
Me.totalDeduct = Double.Parse(Me.amtDedTB.Text.Trim())<br />
<br />
<br />
'TOTAL AMOUNT TO PAY ' DUE TO totalDeduct, this is also not working<br />
Me.totalToPay = (totalInc - totalDeduct)<br />
Me.totalAmtTB.Text = Me.totalToPay.ToString(nfi)<br />
Me.totalToPay = Double.Parse(Me.totalAmtTB.Text.Trim())<br />
<br />
The main problem I believe is coming with absentAmt. If absentAmount is 0, then deducted is fine & hence is total to pay. Otherwise, I get a big no. I have used the same technique & logic, still why is it showing weird with absentAmount.
Can anyone help me figuire out the problem. Any help is appreciated.
Thanks
Thanks
Terry
|
|
|
|
|
It doesn't work that way. NumberFormatInfo applies to format specifiers, not the default format to show any number without a specifier. Do this:
MyTextBox.Text = myDouble.ToString("N4")
Trupti Mehta wrote: ' Calculate UFI WORKING PERFECTLY FINE
uif = ((Me.salary * 1) / 100)
Me.uifTB.Text = uif.ToString(nfi)
uif = Double.Parse(Me.uifTB.Text().Trim())
Please tell me you're not serisously using this to trim a number down to however many decimal places? Are you??
|
|
|
|
|
Dave Kreskowiak wrote: Please tell me you're not serisously using this to trim a number down to however many decimal places? Are you??
Dave, I want to show and save all doubles with just 2 decimal values. That's it. To achieve the goal, I found NumberFormatInfo.DecimalNumber function, that can do the work.
Thanks
Terry
|
|
|
|
|
Trupti Mehta wrote: I found NumberFormatInfo.DecimalNumber function
That's not a function, it's a property of a NumberFormatInfo object, which is part of a culture.
If you want to believe that this will do the job for you, go right ahead and have fun. It's doesn't work the way you think it does.
If you were one of my coders and I saw you rounding a number using this method, I'd probably ask you what youwere thinking, and then fire you. Converting a number to a string, trimming it, then reparsing the numebr?? You honestly can't think of a purely mathematical solution to do this??
|
|
|
|
|
hi there
i m working on this application which involves drawing a line from point A to point B. After the line is drawn i trigger an event and the line has to be redrawn again but this time it should be half the length of the original line and should replace the original line.
At the moment i can draw both the lines but i dont know how to get rid of the original line.
Any ideas/code on how i can go about to solve this problem?
regards
Yasin
|
|
|
|
|
Hello Yasin,
You may draw a line of the length of original line with the Form color which will make original line invisible, then draw second line which is of the half size.
Following is small code snippet which shows this behavior-
--------------------Code Start----------------
Dim myPen As New System.Drawing.Pen(System.Drawing.Color.Red)
Dim formGraphics As System.Drawing.Graphics
formGraphics = Me.CreateGraphics()
formGraphics.DrawLine(myPen, 0, 0, 200, 200)
Dim myPen1 As New System.Drawing.Pen(Me.DefaultBackColor)
formGraphics.DrawLine(myPen1, 0, 0, 200, 200)
formGraphics.DrawLine(Pens.Black, 0, 0, 100, 100)
myPen.Dispose()
myPen1.Dispose()
formGraphics.Dispose()
--------------Code End----------------------
I hope this helps .
-Dave.
Dave Traister,
ComponentOne LLC.
www.componentone.com
|
|
|
|
|
it's easyer to use
formgraphics.Clear(me.BackColor)
be carefull tho it will remove all drawings so if you have anything else drawn to the form they will be removed too
If my help was helpfull let me know, if not let me know why.
The only way we learn is by making mistaks.
|
|
|
|
|
Hi All,
I wanna check for (private,Pvt,(P)) using regular expression in vb.net
and compare two names as ABC private Ltd and A B C pvt Limited
)
Thanks and Regards,
Ahmad
|
|
|
|
|
You might want to check out Expresso[^]. It's a very good regular expression writer/tester.
|
|
|
|
|
How can I read the text file from different position say from position 03(column 1), position 04 to 19 (column2) ..and so on. till the length of record.Then how can I get the values and write the values in csv format?.Please Help out.
C.Sridevi
|
|
|
|
|
Have you looked at the classes in the System.IO namespace?
The File class has static methods for reading and writing text data to files.
I suggest you read the documentation and attempt to write some code based on the examples in MSDN. If you have any specific problems after doing this, come back and ask again.
Paul
|
|
|
|
|
I could read and write the line using stream reader and stream writer.But I need to get the values from a column in a text file.After getting those column values,i need to write it in csv format..how i do this?
C.Sridevi
|
|
|
|
|
Hi,
Here is how to read the file in one chunk (very fast):
<br />
Dim inString As String<br />
Dim stringArray() As String<br />
<br />
fileReader = New System.IO.StreamReader(FileName)<br />
inString = fileReader.ReadToEnd()<br />
fileReader.Close()<br />
stringArray = inString.Split(vbLf)<br />
You will then have to parse each line, in stringArray, separating fields at the relevant points.
That is where you will have to do the work.
What you have asked for does not have a quick and easy answer.
Read up on CSV file formats via google then apply your VB .Net knowledge to parsing each line.
Hope this helps
You always pass failure on the way to success.
|
|
|
|
|
There is no need to write a parser to split the lines into a string array. Look at the Microsoft.VisualBasic.FileIO.TextFieldParser class. It will parse fixed width or CSV text files a line at a time.
|
|
|
|
|
Thanks for that.
Oh man - I wrote a csv classs to read and write csv files
I guess I learnt about csv files in the process though
You always pass failure on the way to success.
|
|
|
|
|
Hi All,
How can I call the existing libraries containing unmanaged C++ classes in a vb.net project.
Thanx In Advance.
Paramhans Dubey.
|
|
|
|
|