|
Here is an example of some loops;
Do
Loop
While (someCondition)
End While
For x = 1 To 10
Next
|
|
|
|
|
For x = 1 To 3
BuyBook()
Next
Do
For Each Book in BookCollection
StudyBook()
End For
Loop Until Me.LoopExpert = True
|
|
|
|
|
what kind of loop do you want to do. Here are several examples of loops: for next, do while, and do until. are all example of looping.
|
|
|
|
|
Hi experts/Friends,
I am learning VB.net and trying to make a ruler for my Text Editor. Following is my try please help me to improve it.
Public Class myRuler
'Inherits System.Windows.Forms.UserControl
Private Sub myRuler_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
Dim g As Graphics = e.Graphics
Dim p As Point = New Point(0, 0)
Dim s As Size = New Size(Me.Width, Me.Height)
Dim curRec As Rectangle = New Rectangle(p, s)
g.DrawRectangle(Pens.Black, curRec)
'Converting Pixels to Twips
Dim ptoTwip As Single = (Me.Width * 15)
'Twips to Inches
Dim twipToInches As Single = CSng(ptoTwip / 1440)
Dim b As Single = 0
'Draw Numders 1 2 3 etc.
For a As Single = 0 To twipToInches
g.DrawString(a, New Font("Arial", 10), Brushes.Black, b, 10)
b = b + 96 '96 192 288
Next
' Dim ptomm As Integer = Me.Width / 3.779527559
'Draw Lines between inches, and long line every 5th
Dim y As Single = 10.0F
For x As Single = 0 To b Step 9.6
g.DrawLine(Pens.Black, x, 0, x, y)
'MessageBox.Show(x)
If x Mod 2 = 0 Then
y = 15
Else
y = 10
End If
Next
End Sub
End Class
|
|
|
|
|
What do you mean by "improve it"?
|
|
|
|
|
Hmm, you could use dark gray instead of black in this bit:
g.DrawString(a, New Font("Arial", 10), Brushes.Black, b, 10)
"I love deadlines. I like the whooshing sound they make as they fly by." (DNA)
|
|
|
|
|
As you have mentioned
nyt1972 wrote: I am learning VB.net
so looks pretty good as far as if you have not copied it from somewhere else , if its working then its Fine what kind of improvement you want in functionality or what , be more descriptive Best Regards,
SOFTDEV
If you have knowledge, let others light their candles at it
|
|
|
|
|
Well you could use Me.ClientRectangle rather than constructing a new rectangle which would save creating three variables.
Maybe go straight from Me.Width to tripsToInches thereby knocking out another variable.
I would also recommend using Me.Font and Me.ForeColor rather than hard coding it so the font decision can be left to the calling code, though fixing the size is probably sensible.
All pretty minor, I had to think to spot these ideas, and they are only ideas.
Basically I can't fault it. Good work.
|
|
|
|
|
That's what I mean The Man from U.N.C.L.E.!
I need Ideas to make this ruler perfect and its not a copy I am trying myself that's why coding is poor 
|
|
|
|
|
|
Hello to All,
Actually i am using a component for Export into Excel . Some time for special value component will be crash and Software generate the error message and Application Will be crash.
So Please help me regarding that how to stop error or how to stop Component crashing.If you can think then I Can.
|
|
|
|
|
is it a third party component or your own devloped component , if your own component then what are those special values ,Try this Code project article if you dont have component code
Export 2 Excel In .Net[^]Best Regards,
SOFTDEV
If you have knowledge, let others light their candles at it
|
|
|
|
|
Yes it is a third party component. and IT is a Control(Visual) on our form.
and It is not for Exporting into Excel. It Shows GUI OF CONTROL for Multiple Purpose.
Thanks for your suggestions.If you can think then I Can.
|
|
|
|
|
I can barely understand what your saying (I think!)
If it's a third party control you're having problems with, your best source of information and support would be the people who wrote the control.
There is no "one fix" that going to stop a control from crashing.
|
|
|
|
|
Thanks Dave,
Actually i want to know that the error only stop from source site.If you can think then I Can.
|
|
|
|
|
HI all
I need to open and program Powermill programs in vb
anyone to help me??
Regards
Gany
|
|
|
|
|
Did you try the forums on their site[^]? That would be your best chance.
|
|
|
|
|
First, never heard of "Powermill".
Second, "opening and program Powermill programs" isn't relaly a specification or good requirement definition. It's WAY too general and does not lend itself to a good answer.
What do you want this thing to do? Let someone edit the program as text? Show a graphical representation of the program? 3D modeling with primitives? ... What?
|
|
|
|
|
i hope so VB means .net not vb6 try the SDK for powermill and also check the Com/ libraries in refrences Best Regards,
SOFTDEV
If you have knowledge, let others light their candles at it
|
|
|
|
|
When I use the following the code to print in prints on one line. How do I put a hard return at the end of each line. So I can have different more than one line.
Private Sub PrintDocument1_PrintPage_1(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
For Me.counter = 0 To 19
e.Graphics.DrawString(writeline(Me.counter), printFont, _
System.Drawing.Brushes.Black, 10, 10)
Next Me.counter
End Sub
by using the follow code resolved the issues
Dim strPrint As New StringBuilder
For Me.counter = 0 To 19
strPrint.Append(printline(Me.counter) & vbCrLf)
Next Me.counter
e.Graphics.DrawString(strPrint.ToString, printFont, System.Drawing.Brushes.Black, 10, 10)
If System.IO.File.Exists(SaveFileDialog1.FileName) Then
printfile = File.OpenText(SaveFileDialog1.FileName)
printfile = System.IO.File.OpenText(SaveFileDialog1.FileName)
Do Until printfile.Peek = -1
menuitem(printcounter) = printfile.ReadLine
e.Graphics.DrawString(printfile.ReadLine, printFont, _
System.Drawing.Brushes.Black, 10, 10)
printcounter = printcounter + 1
Loop
printfile.Close()
End If
now the problem is tab spacing.modified on Thursday, March 11, 2010 1:40 PM
|
|
|
|
|
You need to add a line feed char at the end of each line. Try this :
For Me.counter = 0 To 19
e.Graphics.DrawString(WriteLine(Me.counter & vbCrLf), printFont, System.Drawing.Brushes.Black, 10, 10)
Next Me.counter
Hope this helps.
[EDIT]
Sorry that won't work either. That will print one line on top of another. The best eway to do this is with a stringbuilder like this :
Dim strPrint As New StringBuilder
For Me.counter = 0 To 19
strPrint.Append(counter & vbCrLf)
Next Me.counter
e.Graphics.DrawString(strPrint.ToString, New Font("Ariel", 12), System.Drawing.Brushes.Black, 10, 10)
you will need to import System.Text into your class.
Hope THIS helps.
[/EDIT]modified on Wednesday, March 10, 2010 9:12 PM
|
|
|
|
|
I have tried hard coding the hard return the string array but still did not work.
|
|
|
|
|
Sorry, I don't quite get what you mean, although I tried a test and my second example works perfectly. The only thing was a typo in the font declaration, "Ariel" should be "Arial".
|
|
|
|
|
why are we appending the counter which is an index of the wriline string array.
Dim strPrint As New StringBuilder
For Me.counter = 0 To 19
strPrint.Append(counter & vbCrLf)
Next Me.counter
e.Graphics.DrawString(strPrint.ToString, New Font("Ariel", 12), System.Drawing.Brushes.Black, 10, 10)
should be
<pre><code> Dim strPrint As New StringBuilder
For Me.counter = 0 To 19
strPrint.Append(writeline(me.counter) & vbCrLf)
Next Me.counter
e.Graphics.DrawString(strPrint.ToString, New Font("Ariel", 12), System.Drawing.Brushes.Black, 10, 10)</code></pre>
|
|
|
|
|
You can Check it to Paste it Code to Print Preview Control. If you can think then I Can.
|
|
|
|