|
Okay. It seems that you're right. I'll try to convert the application peace by peace to .NET.
I needed your expert impact for that decision - thanks!
|
|
|
|
|
I feel for you because I used to do that work as well.
Back in the VB6 day.
We used Wise installer to create and deploy our builds, Like VB6 the version we used is no longer supported, but I still use it on my Win7 installs(for another dead language) and it has a very simple method of conditionally installing a file.
I don't use nor do I know NSIS, but it appears the equivalent functionality might be
GetFileAttributes
and/or
GetFileVersion coupled with some flow control logic.
With that in mind, Is it actually necessary to check versions of every file? Could you use a single file to be your gauge. That is, can you check the version of abc.dll or xyz.ocx and based on that version number run a completely different branch of the installer script that could update your dependencies?
One Last comment about large VB6 apps, I found that using two installs was very helpful.
The first install was a CORE installer. It installed all of the dll, ocx, exe files that were dependencies. This was a heavy(big) installer.
The second install was much lighter and it was used to install the primary components of the application. as well as update individual components from the CORE. This file was used to push out updates to the software.
Of course both files were needed for new installs.
This worked well for us because of our business model.
Last, I did have a scriptable builder for VB6, I'll dig around a bit to see if I still have it. It may be something I can share.
rum
|
|
|
|
|
Dear Friends,
i have problem by printing Datagridview content plus header and footer.
i can print exactly DataGridView , but i want to print out the content only (plain text)+ header and footer in vb.net 2010
is anybody can help me to do this !?
Your help would be greatly appreciated
Thanks in advance
|
|
|
|
|
|
Static oColumnLefts As New ArrayList
Static oColumnWidths As New ArrayList
Static oColumnTypes As New ArrayList
Static nHeight As Int16
Dim nWidth, i, nRowsPerPage As Int16
Dim nTop As Int16 = e.MarginBounds.Top
Dim nLeft As Int16 = e.MarginBounds.Left
If nPageNo = 1 Then
For Each oColumn As DataGridViewColumn In frmLedger.dgvLedger.Columns
nWidth = CType(Math.Floor(oColumn.Width / nTotalWidth * nTotalWidth * (e.MarginBounds.Width / nTotalWidth)), Int16)
nHeight = e.Graphics.MeasureString(oColumn.HeaderText, oColumn.InheritedStyle.Font, nWidth).Height + 11
oColumnLefts.Add(nLeft)
oColumnWidths.Add(nWidth)
oColumnTypes.Add(oColumn.GetType)
nLeft += nWidth
Next
End If
Do While nRowPos < frmLedger.dgvLedger.Rows.Count - 1
Dim oRow As DataGridViewRow = frmLedger.dgvLedger.Rows(nRowPos)
If nTop + nHeight >= e.MarginBounds.Height + e.MarginBounds.Top Then
DrawFooter(e, nRowsPerPage)
NewPage = True
nPageNo += 1
e.HasMorePages = True
Exit Sub
Else
If NewPage Then
' Draw Header
e.Graphics.DrawString(Header, New Font(frmLedger.dgvLedger.Font, FontStyle.Bold), Brushes.Black, e.MarginBounds.Left, e.MarginBounds.Top - e.Graphics.MeasureString(Header, New Font(frmLedger.dgvLedger.Font, FontStyle.Bold), e.MarginBounds.Width).Height - 13)
' Draw Columns
nTop = e.MarginBounds.Top
i = 0
For Each oColumn As DataGridViewColumn In frmLedger.dgvLedger.Columns
e.Graphics.FillRectangle(New SolidBrush(Drawing.Color.LightGray), New Rectangle(oColumnLefts(i), nTop, oColumnWidths(i), nHeight))
e.Graphics.DrawRectangle(Pens.Black, New Rectangle(oColumnLefts(i), nTop, oColumnWidths(i), nHeight))
e.Graphics.DrawString(oColumn.HeaderText, oColumn.InheritedStyle.Font, New SolidBrush(oColumn.InheritedStyle.ForeColor), New RectangleF(oColumnLefts(i), nTop, oColumnWidths(i), nHeight), oStringFormat)
i += 1
Next
NewPage = False
End If
nTop += nHeight
i = 0
For Each oCell As DataGridViewCell In oRow.Cells
If oColumnTypes(i) Is GetType(DataGridViewTextBoxColumn) OrElse oColumnTypes(i) Is GetType(DataGridViewLinkColumn) Then
e.Graphics.DrawString(oCell.Value.ToString, oCell.InheritedStyle.Font, New SolidBrush(oCell.InheritedStyle.ForeColor), New RectangleF(oColumnLefts(i), nTop, oColumnWidths(i), nHeight), oStringFormat)
ElseIf oColumnTypes(i) Is GetType(DataGridViewButtonColumn) Then
oButton.Text = oCell.Value.ToString
oButton.Size = New Size(oColumnWidths(i), nHeight)
Dim oBitmap As New Bitmap(oButton.Width, oButton.Height)
oButton.DrawToBitmap(oBitmap, New Rectangle(0, 0, oBitmap.Width, oBitmap.Height))
e.Graphics.DrawImage(oBitmap, New Point(oColumnLefts(i), nTop))
ElseIf oColumnTypes(i) Is GetType(DataGridViewCheckBoxColumn) Then
oCheckbox.Size = New Size(14, 14)
oCheckbox.Checked = CType(oCell.Value, Boolean)
Dim oBitmap As New Bitmap(oColumnWidths(i), nHeight)
Dim oTempGraphics As Graphics = Graphics.FromImage(oBitmap)
oTempGraphics.FillRectangle(Brushes.White, New Rectangle(0, 0, oBitmap.Width, oBitmap.Height))
oCheckbox.DrawToBitmap(oBitmap, New Rectangle(CType((oBitmap.Width - oCheckbox.Width) / 2, Int32), CType((oBitmap.Height - oCheckbox.Height) / 2, Int32), oCheckbox.Width, oCheckbox.Height))
e.Graphics.DrawImage(oBitmap, New Point(oColumnLefts(i), nTop))
ElseIf oColumnTypes(i) Is GetType(DataGridViewComboBoxColumn) Then
oComboBox.Size = New Size(oColumnWidths(i), nHeight)
Dim oBitmap As New Bitmap(oComboBox.Width, oComboBox.Height)
oComboBox.DrawToBitmap(oBitmap, New Rectangle(0, 0, oBitmap.Width, oBitmap.Height))
e.Graphics.DrawImage(oBitmap, New Point(oColumnLefts(i), nTop))
e.Graphics.DrawString(oCell.Value.ToString, oCell.InheritedStyle.Font, New SolidBrush(oCell.InheritedStyle.ForeColor), New RectangleF(oColumnLefts(i) + 1, nTop, oColumnWidths(i) - 16, nHeight), oStringFormatComboBox)
ElseIf oColumnTypes(i) Is GetType(DataGridViewImageColumn) Then
Dim oCellSize As Rectangle = New Rectangle(oColumnLefts(i), nTop, oColumnWidths(i), nHeight)
Dim oImageSize As Size = CType(oCell.Value, Image).Size
e.Graphics.DrawImage(oCell.Value, New Rectangle(oColumnLefts(i) + CType(((oCellSize.Width - oImageSize.Width) / 2), Int32), nTop + CType(((oCellSize.Height - oImageSize.Height) / 2), Int32), CType(oCell.Value, Image).Width, CType(oCell.Value, Image).Height))
End If
e.Graphics.DrawRectangle(Pens.Black, New Rectangle(oColumnLefts(i), nTop, oColumnWidths(i), nHeight))
i += 1
Next
End If
nRowPos += 1
nRowsPerPage += 1
Loop
DrawFooter(e, nRowsPerPage)
e.HasMorePages = False
End Sub
Private Sub DrawFooter(ByVal e As System.Drawing.Printing.PrintPageEventArgs, ByVal RowsPerPage As Int32)
Dim sPageNo As String = nPageNo.ToString + " of " + Math.Ceiling(frmLedger.dgvLedger.Rows.Count / RowsPerPage).ToString
' Right Align - User Name
e.Graphics.DrawString(sUserName, frmLedger.dgvLedger.Font, Brushes.Black, e.MarginBounds.Left + (e.MarginBounds.Width - e.Graphics.MeasureString(sPageNo, frmLedger.dgvLedger.Font, e.MarginBounds.Width).Width), e.MarginBounds.Top + e.MarginBounds.Height + 7)
' Left Align - Date/Time
e.Graphics.DrawString(Now.ToLongDateString + " " + Now.ToShortTimeString, frmLedger.dgvLedger.Font, Brushes.Black, e.MarginBounds.Left, e.MarginBounds.Top + e.MarginBounds.Height + 7)
' Center - Page No. Info
e.Graphics.DrawString(sPageNo, frmLedger.dgvLedger.Font, Brushes.Black, e.MarginBounds.Left + (e.MarginBounds.Width - e.Graphics.MeasureString(sPageNo, frmLedger.dgvLedger.Font, e.MarginBounds.Width).Width) / 2, e.MarginBounds.Top + e.MarginBounds.Height + 31)
End Sub
|
|
|
|
|
Using VB.Net I have created a composit component that inherited a DateTimePicker and that includes a MaskedTextBox as an embedded child class that overlays the DateTimePicker text box. When the user is done editing the MaskedTextBox but has created an invalid date I want the DateTimePicker calander to drop down showing the date that seems closest to what the user entered to get their attention and a confirmation.
I am firing a Delegate method in the MaskedTextBoxes OnValidating event that drops down the calendar after the MaskedTextBox loses focus. The Delegate then selects the DateTimePicker as the active control (overriding any other control selection) and does a SendKey Down to open the calendar. This works great if the target is any control other than the DateTimePicker. But if the DateTimePicker is the target the DateTimePicker gets a double Select and Down keystroke event (one from the delegate and one from the user click) and this messes up other behaviors tied to the MaskTextBox.
I need a way to determine when to fire the Delegate (i.e., when any control other than the DateTimePicker will get focus) and when to not fire the Delegate (i.e., when the DateTimePicker dropdown button was activated by click or keyboard). Is there anyway to do this that would work inside the properties ,methods or events the component can handle? Or is this only possible to detect and manage from the form?
|
|
|
|
|
I found an answer to my question. The Delegate delayed processing until after the OnDropDown event of the DateTimePicker fired. I already had an override of the OnDropDown event to set flags to track the calendar state, so I was able to use one of the flags in the Delegate to suspend it from firing when the Calendar was already being dropped dowm. For anyone's information here is how the events ended up looking:
Private m_bCalAbort As Boolean = False
Private m_bInCal As Boolean = False
Protected Overrides Sub OnDropDown(ByVal eventargs As System.EventArgs)
m_bInCal = True
m_bCalAbort = False
MyBase.OnDropDown(eventargs)
End Sub
Protected Overrides Sub OnCloseUp(ByVal eventargs As System.EventArgs)
'If m_dCalDate <> MyBase.Value Then
If Not m_bCalAbort Then
'Do Stuff
End If
m_bInCal = False
MyBase.OnCloseUp(eventargs)
End Sub
Delegate Sub MyDelegate(ByVal myControl As Label, ByVal myArg2 As String)
Friend Sub DelegateMethod(ByVal myControl As Label, ByVal myCaption As String)
If Not m_DTP.m_bInCal Then
m_DTP.Select()
SendKeys.Send("%{DOWN}")
End If
End Sub 'DelegateMethod
Protected Overrides Sub OnValidating(ByVal e As System.ComponentModel.CancelEventArgs)
m_LastEvent = LastEvents.Validating
If Not DateEmpty() And ue.GetDate(Text) Is Nothing Then ' check for an invalid date
Ping()
Dim myArray(1) As Object
myArray(0) = New Label()
myArray(1) = "Enter a Value"
m_DTP.BeginInvoke(New MyDelegate(AddressOf DelegateMethod), myArray)
ElseIf Not DateEmpty() And ue.GetDate(Text) IsNot Nothing Then
Dim tempdate As DateTime = ue.GetDate(Text)
If tempdate < m_DTP.MinDate Or tempdate > m_DTP.MaxDate Then
Ping()
Dim myArray(1) As Object
myArray(0) = New Label()
myArray(1) = "Enter a Value"
m_DTP.BeginInvoke(New MyDelegate(AddressOf DelegateMethod), myArray)
End If
End If
MyBase.OnValidating(e)
End Sub
modified 26-Sep-12 17:57pm.
|
|
|
|
|
Hi everyone,
Can anyone guide me on how to develop a small telephone tracking system through GPS in vb.net with sql database? How to approach this from a conception point of view. and what i need to take into account.
I have no prior knowledge with GPS and to implement it.
this application is to keep track of all cellphone calls thru GPS and store the data in a database for analysis. this must be done in vb.net with sql.
this is an anti-kidnapping small app.
Thanks advance.
|
|
|
|
|
waner michaud wrote: I have no prior knowledge with GPS and to implement it. ..then I suggest you start there. Windows 7 has a sensor API[^], with the C# intro here[^] (for .NET 4)
The cool part;
Location information may come from multiple providers, such as GPS, Wi-Fi triangulation, and cell phone tower triangulation.
waner michaud wrote: this is an anti-kidnapping small app. That matters little; you could still abuse the technology and do something illegal. I can't tell from here, can I?
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
I am new to VB.net but have been doing ok developing a personal project so far.... since yesterday... The problem is that I got stuck when trying to read the row count of a datagrid that has more than 1500 rows filled with data. The result that I am getting is form2.datagridview1.rows.count - 1 = -1. Which makes no sense since the datagrid is plenty of rows.
Something that I must say is that this datagrid belongs to form2 (a second form that pops-up and shows the datagrid when I call it from From1).
Any thoughts on what could be possibly happening?
Thanks for any advice or comment on this matter.
PS: I'll post my code as soon as I get home
|
|
|
|
|
Actually what I want is to perform a reverse loop search from the last row of the datagrid to the first one.
When I try to obtain the las row index, I always get zero....
|
|
|
|
|
Can you copy/paste the code into your message, formatted with PRE tags?
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
I just figured out that I had to connect again to the database and count the rows of a new created dataset.
I was getting 0 rows because even if the datagrid was full of data, that data came from a previously created dataset that was no longer available. So I really was referencing to a "empty" datagrid.
Problem solved.
Thank you.
|
|
|
|
|
I have an Access database for which I'm trying to write a query based on a request from the users.
I have a table of data related to artwork, with three columns: ArtworkId, DescriptionText, and CalloutNumber. Each piece of artwork can have more than one DescriptionText value.
What would be a good way to write an SQL query to return, for example, all ArtworkId records having both DescriptionText = "Start Switch" and DescriptionText = "Stop Switch" records?
ArtworkID / DescriptionText
123 / Motor
234 / Fuse
234 / Start Switch
456 / Stop Switch
789 / Start Switch
789 / Stop Switch
789 / Light
Result = ArtworkID 789
Any assistance will be greatly appreciated. Thanks!
|
|
|
|
|
I think the follow query would do what you want:
SELECT ArtworkID
FROM Artwork
WHERE DescriptionText In ("Start Switch","Stop Switch")
GROUP BY ArtworkID
HAVING COUNT(*)=2;
|
|
|
|
|
Thanks. I tried something similar this afternoon, but it didn't work. I'll try your idea tomorrow.
|
|
|
|
|
Just happens to work with the example data given. It will show wrong results with duplicated entries, e.g. having two times 357,"Start Switch".
|
|
|
|
|
You are right. If for some reason you can't prevent duplicate entries, then you can use the following query:
SELECT ArtworkID
FROM (SELECT DISTINCT ArtworkID, DescriptionText FROM Artwork) as t1
WHERE DescriptionText In ("Start Switch","Stop Switch")
GROUP BY ArtworkID
HAVING COUNT(*)=2;
It uses a sub-query to get the distinct values first. The rest functions just the same.
|
|
|
|
|
|
For reasons unknown, this didn't work. My intention was for the search text entries to more resemble wildcard text. For example, return all IDs with "switch" or "cable" or whatever in the DescriptionText field.
Thanks for your response.
|
|
|
|
|
You must join the table with itself. Something like:
SELECT a.ArtworkID
FROM Artwork a
INNER JOIN Artwork b
ON a.ArtworkID=b.ArtworkID
WHERE a.DesciptionText="Start Switch" AND b.DescriptionText="Stop Switch"
|
|
|
|
|
Well, that worked. I used 'like' for '=' and surrounded the search text with '%' characters.
Now, suppose I wanted to search using up to 5 terms - would I have to nest the inner joins?
This seems really complicated for something I can see with my eyes & describe easily using English words.
(Also, I tried using the Filter By Form command, but it wouldn't work with my form.
Thanks for the feedback.
|
|
|
|
|
Surely there's an easier way, but this is how I got it to work (I've updated the table and field names):
SELECT *
FROM art_callout_table
WHERE artboardnumber IN (
SELECT artboardnumber FROM art_callout_table
WHERE artboardnumber IN (
SELECT artboardnumber FROM art_callout_table
WHERE lrutext LIKE "%start%")
AND lrutext LIKE "%light%")
AND lrutext LIKE "%switch%";
What confused me repeatedly during development, and what confused the users (they were expecting the search to work one way & I was assuming it to work another), is that there are two distinct search methodologies:
1) Using the built-in Access table filtering commands (or a basic SELECT FROM WHERE statement) to narrow down a table of description text values. Repeated filters can be applied to narrow the list further, but if you're looking for "switch" and "start", all you'll get is individual description text records having both values, eg "big red starting switch" or "switch start light" but not "green switch". Not terribly helpful.
2) Use a different search technique to return all ArtworkID values which have "switch" or "start" or "light" strings within their DescriptionText fields, eg don't look just for DescriptionText records similar to "switch start light blinker".
I thought this was going to be much easier than it turned out to be. Thanks all for your help.
|
|
|
|
|
Good you solved it!
|
|
|
|
|
In a LAN i am having a database on SQL Server express edition.I want to fetch data from this server on some other machine in the same LAN.
I have already done setting in server for allowing remote connections and allowing the firewall setting. etc.
Can anyone tell me from scratch what I have to do on the client PC to fetch data on it in VBA.
|
|
|
|
|