|
I appreciate your help but how to put spaces them because if I am giving spaces between the commands they are getting back in from once again.
|
|
|
|
|
cmd = sshClient.RunCommand("perl something.pl " + something + " " + something1 + " " something2)
Use the best guess
|
|
|
|
|
Thanks my problem is fixed now
|
|
|
|
|
Hi all.
I have a question about program performance. I have a ton of loops all over the place, and a pause button to pause execution. The pause button is pretty much useless right now as it gets superceded by what I figure are long-winded loops. In an attempt to locate the problem loops, I ended up placing temporary DoEvents lines in all of them. The idea was to see if I could get better performance out of the button. Then, I could remove the majority of those DoEvents that did not impact performance all that much. Unfortunately, all that work resulted in no better performance at all for the button. So I have two questions:
1. Is there some utility that can pinpoint where the majority of a program spends its time, without placing timers or stopwatches everywhere.
2. Are their certain events or API functions that can essentially "shut-down" DoEvents lines?
Thanks for any advice!
|
|
|
|
|
DoEvent was never going to get you any performance benefit, and, frankly, we're all looking at you funny for even thinking so.
DoEvents stops your code and execute all the messages pending in your apps message pump. Nothing more...
What you're looking for is a code profiler. If you have an Ultimate Edition of Visual Studio, it's built in. If not, you'll have to use a third party product, none of which are free.
|
|
|
|
|
I'm probably not explaining myself clearly. If you have a long-winded loop somewhere and want to pause execution for some reason, you can't do it with a button click unless you have a DoEvents line in there so that the loop can stop long enough to process system events. By "performance", I meant that the "performance" of the Pause button improves because now it has a chance to be processed in the middle of the loop. I know that DoEvents() slows things down for exactly the reason you point out, but under the circumstances, unless there is an alternative to DoEvents(), I'm stuck.
But the other possible explanation of the problem is that somehow, no matter what loops I put my DoEvents lines in, something shuts them down so that they do not respond. Is that likely?
|
|
|
|
|
treddie wrote: you have a long-winded loop somewhere and want to pause execution for some
reason, you can't do it with a button click unless you have a DoEvents line in
there
Wrong. The correct technique is to move the long running operation to a background thread. Then you don't need DoEvents (and the headaches that come with it) and just set a flag or some other synchronization object. That way your UI isn't blocked.
|
|
|
|
|
Ah...OK. I need to think parallel these days.
And thanks for the info on code profilers. I did do a quick search and found a couple of free ones, though I don't know if they are any good, or for that matter, truly "free" (aka fully-functional, non-demo).
Thanks for the help. Much appreciated!
|
|
|
|
|
Just make sure you're not using a memory profiler. Those are a bit more common and some of those are free. They're not the same as a code profiler.
|
|
|
|
|
To determine where your code is spending time, consider using some sort of switchable logging. Use a boolean operator to turn logging on/off, or a variable to set the level of desire logging.
Then, if logging is enabled, mark in a log the entry and exit time of each routine, each loop, each loop iteration, etc as desired.
Is is pretty? No, but if you don't have funds available to purchase a professional product, it provides a solution.
|
|
|
|
|
Heheh...That's why I didn't want to go that route. It's a lot of work that is for temporary use. Oddly, though, I had already set up a logging system for this program to write to a text file at key points in the code, so that any customers who buy my program could send me that file if they run into any bugs. The only thing missing are the time stamps. So, come to think of it, since it's already in place, it's not such a big deal to add time stamps.
As for the two profilers I located:
This one is free, but appears tailored to AMD chips:
http://developer.amd.com/tools/heterogeneous-computing/amd-codeanalyst-performance-analyzer/
This company has a free version of their product, but didn't have time to check what it's limitations are:
http://eqatec.com/Profiler/Download.aspx?BannerId=1&VendorId=1&PortalId=0
modified 28-May-13 14:14pm.
|
|
|
|
|
hello everyone,
is there anyone could help me to this problem, I have downloaded a module file which is (exifReader), then I apply it to my system code. when I browse an image from a folder or file when I click the a button to show the properties of the image and put it to some textbox, I got this error saying " run time error 9 , Subcription out range",
this is the code for showing the properties of the image :
Private Sub Command1_Click()
If Picture1.Picture = 0 Then
MsgBox ("Insert Image First")
Else
Text6.Text = CommonDialog1.FileName
Text3.Enabled = False
Dim objexif As New ExifReader
objexif.Load (Text6.Text)
Text2.Text = objexif.Tag(GPSLongitude)
Text3.Text = objexif.Tag(GPSLatitude)
Text4.Text = objexif.Tag(GPSInfo)
Text5.Text = objexif.Tag(DateTimeOriginal)
Text2.Enabled = False
Text6.Enabled = False
Text3.Enabled = False
End If
End Sub
//*******
and this the module part of code where the error shows.
Private Function InspectJPGFile() As Boolean
Dim i As Long
If ExifTemp(0) <> &HFF And ExifTemp(1) <> &HD8 Then
InspectJPGFile = False
Else
///this line is having error, subscription out of range///
For i = 2 To UBound(ExifTemp) + 1
If ExifTemp(i) = &HFF And ExifTemp(i + 1) = &HE1 Then
Offset_to_APP1 = i
Exit For
End If
Next
If Offset_to_APP1 = 0 Then
InspectJPGFile = False
End If
Offset_to_TIFF = Offset_to_APP1 + 10
Length_of_APP1 = _
ExifTemp(Offset_to_APP1 + 2) * 256& + _
ExifTemp(Offset_to_APP1 + 3)
If Chr(ExifTemp(Offset_to_APP1 + 4)) & Chr(ExifTemp(Offset_to_APP1 + 5)) & _
Chr(ExifTemp(Offset_to_APP1 + 6)) & Chr(ExifTemp(Offset_to_APP1 + 7)) <> "Exif" Then
InspectJPGFile = False
Exit Function
End If
InspectJPGFile = True
End If
if the codes are not enough to analyze please tell me and I post all the code for exifreader class module, any idea and help are really appreciated. thanks..
by the way I use Visual basic 6.0.. ^_^
jonel
|
|
|
|
|
You shouldn't be using VB^ for any new development as the language has been dead and unsupported for years now.
But, look at your For loop and the bounds you used. You're asking it to give you the upperbound of the ExifTemp array, and then you're adding 1 to it. Uh, it just told you that the upper bound is this value and you ignored it and tried to go higher than that. You cannot index into an array higher than the upper bound it just gave you!
|
|
|
|
|
hi
i'm doing the vb project
how to record the videos and saving the videos in vb6
please send the codes
|
|
|
|
|
Firstly you don't want to be doing this in VB6 - it's an unsupported language.
Using VB.NET would be better (I'd use C# but that's just my preference).
Secondly you can't record videos in any language ... but you can interface to a camera - exactly how may depend on which camera you use.
This article does some stuff with a webcam - it's in C# but there are plenty of ways of converting into VB for free (look on Google)
Versatile WebCam C# library[^]
|
|
|
|
|
Hello guys,
I posted a question earlier and gut a reply but i dont know how to reply to them, anyway thanks Zoltan and Ron. here is my question, "i have two forms, form1 and form2. i have a button in form1 to show form 2. but when i move form1 and click the button form2 show not in the center. I want form2 always show in the center of form1 even it from another location. thanks. what i got here is this code but it gives me and error in "Me", please help
code
Dim Show_login As New form2
Show_login.StartPosition = FormStartPosition.CenterParent
Show_login.Parent = Me
Show_login.Show()
|
|
|
|
|
athan_makubex wrote: gut a reply but i dont know how to reply to them Try clicking the "Reply" link at the bottom of the message.
Use the best guess
|
|
|
|
|
|
Hi
try this way : select Form2 property and look at layout options
then StartPosition : Centerscreen (or whatelse available , centerparent..)
Regards
modified 20-May-13 2:44am.
|
|
|
|
|
Hi All,
i have an Excel which contains 25 columns.Treating it as source file,i need to generate a report which needs to display 3 columns ,also i need to evaluate some calculations and need to display in a newly created column..
Requestname,status and validity.i need to display only these columns in my report.In addition to that i need to calculate the num of requests based on the status/validity values and need to display in seperate column "number of requests".
also we need to calculate the difference between the time based on two columns(format mm/dd/yyyy hh:mm) and put in a seperate column to display.
If this is the wrong window,please suggest me the apt place to post.
|
|
|
|
|
Well, you have told us what your requirements are, but not what the problem is that you are facing. If you are expecting someone to write the code for you, you have come to the wrong place.
Use the best guess
|
|
|
|
|
Hi everybody, am going to show you a sample program which enables to print the contents of a datagridview, the program works properly despite a minor error which occurs before the printing is done it says OBJECT REFERENCE NOT SET TO AN INSTANCE OF AN OBJECT, although it does not prevent the program from meeting the purpose. i would like to share it with you, and atleast we can discus on how to remove that error.
The program is based on the customers table of the Northwind Database.
On my form there is a datagridview named Mydatagridview, A print button called btnPrint
Below is the VB code ..............
Imports System.Data.OleDb
Imports System.Drawing.Printing
Imports System
Imports System.Collections
Imports System.ComponentModel
Imports System.Data
Imports System.Text
Imports System.Windows.Forms
Imports System.Drawing
Public Class Form1
Private WithEvents printDocument1 As New PrintDocument
'Used to save left coordinates of columns
Dim arrColumnLefts = New ArrayList()
'Used to save column widths
Dim arrColumnWidths = New ArrayList()
'Used to get and set the datagridview cell height
Dim iCellHeight As Integer = 0
Dim iTotalWidth As Integer = 0
'Used as counter
Dim iCount As Integer = 0
Dim iRow As Integer = 0
'Used to check whether we are printing first page
Dim bFirstPage As Boolean = False
'Used to check whether we are printing a new page
Dim bNewPage As Boolean = False
'Used for the header height
Dim iHeaderHeight As Integer = 0
Dim strFormat = New StringFormat()
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim con As New OleDb.OleDbConnection
con.ConnectionString = "provider=microsoft.jet.oledb.4.0; Data source= " & Application.StartupPath & "\Customers.mdb"
Dim ds As DataSet = New DataSet()
Dim dt As New DataTable
Dim da As OleDbDataAdapter = New OleDbDataAdapter("SELECT CompanyName,ContactName,Address,PostalCode,Phone from Customers2", con)
Me.WindowState = FormWindowState.Maximized
Try
da.Fill(ds, "dt")
da.Fill(ds, "Customers2")
MyDataGridView.DataSource = ds
MyDataGridView.DataMember = "dt"
Catch ex As Exception
MessageBox.Show("Operation failed: " + ex.ToString(), Application.ProductName + " - Error", MessageBoxButtons.OK, MessageBoxIcon.[Error])
Return
End Try
End Sub
Private Sub btnPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrint.Click
'Open the print dialogue
Dim MyPrintDialog = New PrintDialog()
MyPrintDialog.Document = printDocument1
MyPrintDialog.UseEXDialog = True
'Get the document
If Windows.Forms.DialogResult.OK = MyPrintDialog.ShowDialog() Then
printDocument1.DocumentName = "Test page print"
printDocument1.Print()
End If
End Sub
Private Sub printDocument1_BeginPrint(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintEventArgs) Handles _
printDocument1.BeginPrint
' MsgBox("starting printpage")
Try
strFormat.Alignment = StringAlignment.Near
strFormat.LineAlignment = StringAlignment.Center
strFormat.Trimming = StringTrimming.EllipsisCharacter
arrColumnLefts.Clear()
arrColumnWidths.Clear()
iCellHeight = 0
bFirstPage = True
bNewPage = True
'Calculating Total Widths
iTotalWidth = 0
For Each dgvGridCol As DataGridViewColumn In MyDataGridView.Columns
iTotalWidth = iTotalWidth + dgvGridCol.Width
Next
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Private Sub printDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles _
printDocument1.PrintPage
Try
'Set the left margin
Dim iLeftMargin As Integer = e.MarginBounds.Left
'Set the top margin
Dim iTopMargin As Integer = e.MarginBounds.Top
'Whether more pages have to print or not
Dim bMorePagesToPrint As Boolean = False
Dim iTmpWidth As Integer = 0
'For the first page to print set the cell width and header height
If bFirstPage = True Then
For Each Gridcol As DataGridViewColumn In MyDataGridView.Columns
iTmpWidth = CType(Math.Floor(CType(CType(Gridcol.Width, Double) / CType(iTotalWidth, Double) * CType(iTotalWidth, Double) * (CType(e.MarginBounds.Width, Double) / CType(iTotalWidth, Double)), Double)), Integer)
iHeaderHeight = CType((e.Graphics.MeasureString(Gridcol.HeaderText, Gridcol.InheritedStyle.Font, iTmpWidth).Height) + 11, Integer)
'Save width and height of headers
arrColumnLefts.Add(iLeftMargin)
arrColumnWidths.Add(iTmpWidth)
iLeftMargin = iLeftMargin + iTmpWidth
Next
End If
'Loop till all the grid rows not get printed
While iRow <= MyDataGridView.Rows.Count - 1
Dim GridRow As DataGridViewRow = MyDataGridView.Rows(iRow)
'Set the cell height
iCellHeight = GridRow.Height + 5
Dim iCount As Integer = 0
'Check whether the current page settings allo more rows to print
If iTopMargin + iCellHeight >= e.MarginBounds.Height + e.MarginBounds.Top Then
bNewPage = True
bFirstPage = False
bMorePagesToPrint = True
Exit While
Else
If bNewPage = True Then
'Draw header
e.Graphics.DrawString("Fibre Requirements", New Font(MyDataGridView.Font, FontStyle.Bold), Brushes.Black, e.MarginBounds.Left, e.MarginBounds.Top - e.Graphics.MeasureString("Customer Summary", New Font(MyDataGridView.Font, FontStyle.Bold), e.MarginBounds.Width).Height - 13)
Dim strDate As String = DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToShortTimeString()
'Draw Date
e.Graphics.DrawString(strDate, New Font(MyDataGridView.Font, FontStyle.Bold), Brushes.Black, e.MarginBounds.Left + (e.MarginBounds.Width - e.Graphics.MeasureString(strDate, New Font(MyDataGridView.Font, FontStyle.Bold), e.MarginBounds.Width).Width), e.MarginBounds.Top - e.Graphics.MeasureString("Customer Summary", New Font(New Font(MyDataGridView.Font, FontStyle.Bold), FontStyle.Bold), e.MarginBounds.Width).Height - 13)
'Draw Columns
iTopMargin = e.MarginBounds.Top
For Each GridCol As DataGridViewColumn In MyDataGridView.Columns
e.Graphics.FillRectangle(New SolidBrush(Color.LightGray), New Rectangle(CType(arrColumnLefts(iCount), Integer), iTopMargin, CType(arrColumnWidths(iCount), Integer), iHeaderHeight))
e.Graphics.DrawRectangle(Pens.Black, New Rectangle(CType(arrColumnLefts(iCount), Integer), iTopMargin, CType(arrColumnWidths(iCount), Integer), iHeaderHeight))
e.Graphics.DrawString(GridCol.HeaderText, GridCol.InheritedStyle.Font, New SolidBrush(GridCol.InheritedStyle.ForeColor), New RectangleF(CType(arrColumnLefts(iCount), Integer), iTopMargin, CType(arrColumnWidths(iCount), Integer), iHeaderHeight), strFormat)
iCount = iCount + 1
Next GridCol
bNewPage = False
iTopMargin += iHeaderHeight
End If
iCount = 0
'Draw Columns Contents
For Each Cel As DataGridViewCell In GridRow.Cells
If Not IsDBNull(Cel.Value) Then
e.Graphics.DrawString(Cel.Value.ToString(), Cel.InheritedStyle.Font, New SolidBrush(Cel.InheritedStyle.ForeColor), New RectangleF(CType(arrColumnLefts(iCount), Integer), CType(iTopMargin, Single), CType(arrColumnWidths(iCount), Integer), CType(iCellHeight, Single)), strFormat)
End If
'Drawing Cells Borders
e.Graphics.DrawRectangle(Pens.Black, New Rectangle(CType(arrColumnLefts(iCount), Integer), iTopMargin, CType(arrColumnWidths(iCount), Integer), iCellHeight))
iCount = iCount + 1
Next
End If
iRow = iRow + 1
iTopMargin = iTopMargin + iCellHeight
End While
'If more lines exist, print another page.
If bMorePagesToPrint = True Then
e.HasMorePages = True
Else
e.HasMorePages = False
End If
Catch exc As Exception
MessageBox.Show(exc.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
End Class
|
|
|
|
|
Use your debugger to locate the exact point at which the error occurs and then show just that portion of code (within <pre> tags), and the content of all the local variables. Although, the debugger will clearly show you which object reference has not been initialised.
Use the best guess
|
|
|
|
|
Evord wrote: Hi everybody, am going to show you a sample program We have samples on datagridprinters in the Article-section. This isn't a sample, it's a code-dump with a question. Let's focus on the question and solving it, shall we?
Instead of showing "exc.Message", try "exc.ToString()"; that way the messagebox will show on which line the error occured. That'd be easier in tracing the exception than reading the entire code and checking each line.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
My class is now over. I had an issue with the the assignment. I couldn't get the program to find and display the duplicate random numbers. I've looked for almost two weeks for an answer and I'm hoping that someone here can help me.
This was the assignment:
Present the following report – (you will modify this based on user input and the actual rolls.
Number of dice:2
Number of sides:6
Number of rolls:2
Dice 1 Roll 1 = 5
Dice 2 Roll 1 = 6
Dice 1 Roll 2 = 1
Dice 2 Roll 2 = 1
Number of rolls where all dice were the same: 1
I got everything but the number of rolls where all the dice were the same. Can someone please advise me as to how this should have been done?
Here is a snippet of what I did:
'Start the randomization process
Dim RandomClass As New Random() 'Our random number generator
Dim vRoll() As Integer 'User entered variable for the array
ReDim vRoll(nDice) 'dynamic number entered by the user
Dim cntDice As Integer = 0
Dim myArray As New List(Of Integer)
Dim temp As Integer
myArray.Clear()
'Get the number of rolls and the number of dice and then randomize the rolls.
For i As Integer = 1 To rRoll
For j As Integer = 1 To nDice
temp = RandomClass.Next(1, dSize + 1)
LST_Items.Items.Add("Dice " & j & " Roll " & i & " = " & temp.ToString)
If Not myArray.Contains(temp) Then
cntDice += 1
LBL_Same.Text = cntDice
Else
LBL_Same.Text = "0"
End If
Next
Next
So if anyone is willing to give me advice I would greatly appreciate it.
Thanks!
Troy E Bouchard
|
|
|
|
|