|
|
The easiest was is to make the contents of the form a control, which you can then put where-ever you like.
Christian Graus - C++ MVP
|
|
|
|
|
|
You just add it the same as any in built control, in the designer, or in code.
Christian Graus - C++ MVP
|
|
|
|
|
|
I have a simple VB6 class in a DLL that has two functions , AllocateLargeArray and DeAllocateLargeArray. I am driving the DLL from an MFC App and in this App I have a button that creates an interface to the VB Class and calls the two functions then releases.
If I then look at the Apps Private bytes (VM Size in TM) of the process the value seems to initially increase lots say to 1900k then on subsequent presses of the button drop to 1600k again to 1300k again to 1000k and then shoot back up to 1900k !
Can anyone tell me why is behaviour ?
To aid here is a a snippet of the code I have in VB.
Thanks.
<br />
Option Explicit<br />
<br />
Dim mCollection As Collection<br />
<br />
Public Function AllocateLargeArray()<br />
Dim loc As MyStruct<br />
Dim ii As Integer<br />
<br />
Set mCollection = Nothing<br />
Set mCollection = New Collection<br />
<br />
For ii = 1 To 10000<br />
Set loc = New MyStruct<br />
mCollection.Add loc<br />
Next ii<br />
End Function<br />
<br />
Public Function DeAllocateLargeArray()<br />
Dim ii As Integer<br />
ii = 1<br />
<br />
Do While ii <= mCollection.Count<br />
mCollection.Remove ii<br />
Loop<br />
<br />
Set mCollection = Nothing<br />
End Function<br />
|
|
|
|
|
First, don't use Task Manager to get the memory statistics. Use Performance Monitor instead. Next VB6's memory management is just about entirely automatic.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
For viewing the private bytes values I was using process explorer rather than Task Manager though bar the dodgy naming for certain values task manager should be ok.
Also im not sure what you mean by 'entirely automatic'. Surely there has to be some reasoning to what seems to be happening.
|
|
|
|
|
Well, Task Manager is about the worst tool you can use unless you REALLY know what your looking at.
For example, under the .NET CLR, you're seeing the memory reserved for the .NET CLR virtual machine your app is running in, not the amount of memory your app is actually using.
As for the VB^ memory manager, I haven't touched VB6 since Visual Studio .NET 2002 Beta 1 came out, about 5-6 years ago.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi there!
I'm making a syntax highlighter and I've come a long way, everything works perfectly... as long as you write on the first line. When moving to the next lines and writing the words that are supposed to be highlighted only the first line is colored, with the color that's set for the most recent match, why does this occur and how can I solve it?
'searches teh text and colors it...<br />
Private Sub ExtendedRichTextBox_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ExtendedRichTextBox.TextChanged<br />
<br />
Dim selectionAt As Integer = ExtendedRichTextBox.SelectionStart<br />
<br />
'find out the linenumber...<br />
lineNumber = ExtendedRichTextBox.GetLineFromCharIndex(ExtendedRichTextBox.SelectionStart()) + 1<br />
<br />
If ExtendedRichTextBox.GetFirstCharIndexFromLine(lineNumber) = -1 Then<br />
line = ExtendedRichTextBox.Text.Substring(ExtendedRichTextBox.GetFirstCharIndexOfCurrentLine())<br />
startCharIndex = 0<br />
Else<br />
line = ExtendedRichTextBox.Text.Substring(startCharIndex, ExtendedRichTextBox.GetFirstCharIndexFromLine(lineNumber) - ExtendedRichTextBox.GetFirstCharIndexOfCurrentLine)<br />
End If<br />
<br />
'regular expression...<br />
Dim reg_exp As Regex<br />
<br />
'give reg_exp some values...<br />
For i As Integer = 0 To 4<br />
<br />
'give reg_exp a value from the array...<br />
reg_exp = New Regex(syntaxText(i))<br />
<br />
'search for matches...<br />
Dim match As Match<br />
match = reg_exp.Match(line)<br />
<br />
'give the match the right color...<br />
If reg_exp.IsMatch(line) Then<br />
<br />
With ExtendedRichTextBox<br />
.Select(match.Index, match.Length)<br />
.SelectionColor = syntaxColor(i)<br />
.SelectionStart = selectionAt<br />
.SelectionColor = textColor<br />
End With<br />
<br />
End If<br />
Next<br />
<br />
End Sub
Thank you in advance!
|
|
|
|
|
Hi,
Apparently you have written an entire class (Regex), as well as a few functions that are called but not shown in your example. I don't have an ExtendedRichTextBox in my toolbox, so I am guessing that this too is either self made or maybe comes from a third party addon to .NET?
Anyway, all I could find in your code was that you give your variable startCharIndex a value of 0 if something happens, but if it doesn't, this variable does not get a value assigned. The only other code I see that seems funny to me, is the whole last "with ExtendedRichTextBox" bit (unless your function syntaxColor() does something to the color of the selected text before you change it to textColor.
Otherwise my guess is, that the mistake should be searched in another part of your code.
Good luck with this one,
Johan
|
|
|
|
|
I am creating a unique serial number for my ticket submissions.
I use the two letter state abbreviation, the julian date, and milleseconds to create the ticket number. ex"Ticket #: IA20063171383477656". This has been working great. But recently my code has
became flawed. My tickets are getting a hyphen inserted between the julian date and the milliseconds. I found this is because of a bug in the TimeGetTime() function. It starts to give negative numbers after a certain amount of uptime. How do I fix this negative number?
I need to keep the tickets sequential through the day. So 12:00am to 11:59pm will be one sequence of tickets then the sequence will change to the next julian date. Can someone please help me?
I have placed my code below.
Thanks
<script runat="server">
Public Function Date2Julian(ByVal vDate As Date) As Long
Date2Julian = CLng(Format(Year(vDate), "0000") _
+ Format(DateDiff("d", CDate("01/01/" _
+ Format(Year(vDate), "0000")), vDate) _
+ 1, "000"))
End Function
</script>
<script runat="server">
Sub SendMail(sender As Object, e As System.EventArgs)
Dim MyDate as String
MyDate = Date.Now.ToString("MM/dd/yyyy")
Dim Julian as String
Julian = "IA" & Date2Julian(MyDate)& TimeGetTime()
Ticket_ID.Value= Julian
End Sub
</script>
|
|
|
|
|
You didn't post the code your using to define TimeGetTime, but I'm betting that your using an Integer, or some other signed data type, to return the value of TimeGetTime. Use an unsigned data type to return the time in milliseconds, like UInt32 or UInteger.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I get TimeGetTime() from winmm.dll out of the Windows multimedia SDK.
Private Declare Function timeGetTime Lib "winmm.dll" () As Integer
|
|
|
|
|
The C function header specifies a DWORD return value, which is an unsigned 32-bit integer. You have to use the equivilent type in your own code:
Private Declare Function timeGetTime Lib "winmm.dll" () As UInt32
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Ok,
That removed the negative value. But it also shortened the length of the string.
My main worry is that I will somehow get the same number within a 24 hour period
due to rounding. This would place new tickets in front of old tickets and place them
out of sequence.
Old Format - Ticket #: IA20063171394281750
New Format - Ticket #: IA2006320857714024
Instead of using timegettime() is there any way to get the milliseconds since midnight of today.
Basically I need it to reset every 24 hours.
If todays julian date is 320 I want the ticket to look like IA 2006320 and then the milliseconds since midnight. This way it does not duplicate within a 24 hour period.
Can you please tell me how to do that?
|
|
|
|
|
It's simple math...
Dim currentTime As DateTime = DateTime.Now()
Dim msSinceMidnight As Integer
msSinceMidnight = currentTime.Millisecond + _
currentTime.Second * 1000 + _
currentTime.Minute * 60000 + _
currentTime.Hour * 3600000
Instead of going through all this, why not just have the database use a compound key and generate the last part of the key with an autonumber field?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I did this but it didn't work
<script runat="server">
Public Function Serialize() as String
Dim currentTime As DateTime = DateTime.Now()
Dim msSinceMidnight As Integer
msSinceMidnight = currentTime.Millisecond + _
currentTime.Second * 1000 + _
currentTime.Minute * 60000 + _
currentTime.Hour * 3600000
End Function
</script>
It gives me an error in VS 2005. "Function 'Serialize' doesn't return a value on all code paths. A null reference exception could occur at run time when the result is used."
Also is there a way to pad the string with zeros so that the string is always the same length?
There are 86400000 milliseconds in a day starting at 00000001 and ending at 86400000.
Thanks
|
|
|
|
|
Uhhh...of course it didn't work! Your function didn't return any value, as detailed by the error message you got. You also specified a return type of String, but didn't do any conversion of the number to a string, before you DIDN'T return the value.
This is BASIC 101 stuff you missed. I would highly suggest picking up a book on VB.NET before you try to put together a web site using it.
Public Function Serialize() As String
Dim currentTime As DateTime = DateTime.Now()
Dim msSinceMidnight As Integer
msSinceMidnight = currentTime.Millisecond + _
currentTime.Second * 1000 + _
currentTime.Minute * 60000 + _
currentTime.Hour * 3600000
Return String.Format("00000000", msSinceMidnight)
End Function
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hello,
I have just had a error deploying a clickonce application. The error is below and has been solved
System.Runtime.InteropServices.COMException (0x80040154): Retrieving the COM class factory for component with CLSID {10020200-E260-11CF-AE68-00AA004A34D5} failed due to the following error: 80040154.
The above problem caused me hours to solve. However, was solved my simply by doing the following: regsvr32 sqldmo.dll. to register the dll on the client machine.
I have created a deployment using the MSI, and never had this problem. But clickOnce does cause this problem if the dll does not exist and is not registered on the client machine.
Is there any way that you can use clickone to add this dll on the client's machine, so I don't have to go to trouble of registering manually.
When I publish this file I have added all the required dlls.
This is what I have done:
1. In the solution explorer | references | properties | set the sqldmo local copy to true
2. On the publish tab | Application File | set the publish status for the sqldmo.dll to include and required
3. Prereqisities | Added the .net framework, CR Reports .Net, MS Data Access components.
VB 2005 & SQL Server 2005.
Many thanks for any help,
Steve
|
|
|
|
|
I need to highlight the an item in the list box, here is the code:
If MyCameraSchedules.Length = 1 Then
lstScheduleNames.SelectedIndex = 0
Else
lstScheduleNames.SelectedIndex = MyCameraSchedules.Length - 1
End If
So basically if I have more than 1 schedule, I want to highlight the last schedule in the list box, if only 1 then highlight the first item which is index 0. However, I get an Exception complaining object reference not set to an instance of object.
I also refresh() the listbox, but doesn't help.
Anyone?
Waiting
|
|
|
|
|
Given the code you gave, the only thing that would be not set to an instance would be the MyCameraSchedules and not the listbox. Have you verified that MyCameraSchedules is set?
|
|
|
|
|
It should be as simple as this:
If MyCameraSchedules.Length > 0 And lstScheduleName.Items.Count >= MyCameraSchedules.Length Then
lstScheduleNames.SelectedItem = lstScheduleNames.Items.Count - 1
End If
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Thanks, but for some odd reason that still doesn't highlight the item if there is only one item in the list box.
If there are more items, then it always highlights the first item.
What I need to do is highlight the first item if only item, otherwise highlight the last.
Thanks b4 hand
Yoshimitsu
|
|
|
|
|
Thanks Dave, This solved the problem
If MyCameraSchedules.Length = 1 Then
lstScheduleNames.SelectedIndex = lstScheduleNames.Items.Count - 1
Else
lstScheduleNames.SelectedIndex = MyCameraSchedules.Length - 1
End If
Yoshimitsu
|
|
|
|