|
Phoenix the bird for programming.
|
|
|
|
|
So do I. But, from MS' point of view, it's dead, buried and decaying.
|
|
|
|
|
I am new in Thread and want to use two functions in diff. thread.
My functions are-
sendData() and sendInfo()
How can i start that these two functions call in diff. thread and can run at same time.
Plz explain in detail..
Thanks in adv..
|
|
|
|
|
VB6 doesn't support threading. There are work arounds to do this, but you better know what you're doing and why. Also, the debugger does not support debugging multithreaded code. Try it and you'll crash the IDE.
If you really want to do threading, drop VB6 and pickup VB.NET.
|
|
|
|
|
As Dave already mentioned, you don't want to call CreateThread from VB6. You can find example-implementations on the internet, but most aren't complete and it seldom a good idea. For an in-depth explanation, check this[^] article.
There are some alternatives, like encapsulating your thread in a complete executable. The best option to add multithreading to an existing VB6 application, is by using VB.NET; you can use the InterOp Toolkit[^] to extend your VB6 application with VB.NET specific code. You could create a new form in VB.NET, add as much threading as you like, and load that form from VB6.
If it's a new project then you'd best move on to VB.NET.
I are Troll
|
|
|
|
|
hi to all..
I have two dynamic array bOdt and bodtEntry byte arrays. which are declared as follow-
Dim bOdt() As Byte
Dim bOdtzentry() As Byte
and I am passing BOdt in a function as two dimension array but still it is dynamic.Now I want to store this bOdt array in another array bOdtEntry and change size of the array.
My code is as follow-
Public Function fOdtEntry(count As Integer, bOdt() As Byte) As Variant
Dim FlagRem As Integer
Dim FlagDiv As Integer
Dim RefCntr As Byte
ReDim bOdtEntry(0 To count, 0 To 9) As Byte
bOdtEntry = bOdt
bOdtEntry(count, 0) = bGet(8)
bOdtEntry(count, 1) = bGet(9)
and so on..
On compilation it is giving an error."Subscribe out of range"
Plz help what may be the problemmmmm??
Thanks in adv.
|
|
|
|
|
If you are using Option Base 0 then count will be 1 higher than the upperbound index.
you should not use fixed values, but use Ubound and if you do use count then subtract 1 for the highest index.
|
|
|
|
|
thanks for replay..
But i am not getting it.
I am using base 0 and count is the ubound of array....
Can u explained in detail..
Thanks
|
|
|
|
|
If you are using Base 0 then look at the following example for an array called Names;
Index - Item
-------------
0 - Fred
1 - Jim
2 - Bob
3 - Frank
4 - Jack
Count = 5, LBound = 0, UBound = 4
So,
Names(0) = Fred
Names(4) = Jack
Names(Count-1) = Jack
Names(Count) = Out Of Limits Error
Does that explain it better?
|
|
|
|
|
thanks for ur reply..
I got the solution..
|
|
|
|
|
Hi Guys,
I have a Crystal report with a sub report.
i need to set the subreport to use paper from an alt. tray from the printer.
any ideas?
rptMain.Subreports(0).PrintOptions.CustomPaperSource = GetSelectedPaperSource(Me.cbDft.Text.Trim)
Private Function GetSelectedPaperSource(ByVal paper As String) As System.Drawing.Printing.PaperSource
Try
Dim selectedPaperSource As System.Drawing.Printing.PaperSource = New System.Drawing.Printing.PaperSource
Dim myPrinterSettings As System.Drawing.Printing.PrinterSettings = New System.Drawing.Printing.PrinterSettings()
myPrinterSettings.PrinterName = Me.lblPrinter.Text.Trim
For Each myPaperSource As System.Drawing.Printing.PaperSource In myPrinterSettings.PaperSources
If myPaperSource.SourceName = paper Then
Return myPaperSource
End If
Next
Catch ex As Exception
Throw New Exception(ex.Message & vbCrLf)
End Try
End Function
thanks
|
|
|
|
|
Hi
if you placed (almost) any control on the form (textbox,combo,datetimepicker,groubbox) and set the property "Enable" to "false" you can notice that there color has changed to light-grey color, but if you set "Enabled = false" for the datagridview I cannot distinguish any changes from "Enabled = true".
I want the ability of telling that this datagridview is enabled or disabled by looking to it, not by moving the mouse over it and test if it will take focus or no.
Thanks.
modified on Tuesday, September 7, 2010 5:06 AM
|
|
|
|
|
For a datagridview it is better to use the read-only property.
If you disable the control everything inside the control is disabled so if there are any scroll bars (horizontal or vertical) your user won't be able to scroll.
With read-only the user will still be able to scroll.
As for a visual clue, you'll have to write something yourself to do that.
You can use the 'enabledchanged' and/or 'readyonlychanged' events for that.
|
|
|
|
|
I have a VB application that updates one database using input from another database. The code looks like:
Dim InputDC as OldDatabaseConnection
Dim OutputDC As ...
InputDC.Open
OutputDC.Open
For each table in Input Database
Read data from old table
Copy data to new table
Write new table to Output database
...
InputDC.Close
OutputDC.Close
Sometimes [often] the Output database does not close, that is the Output.ldb file is left hanging around for an indefinite time period. Sometimes the program runs fine e.g. 50 times in a row; then suddenly it will hang. I've been programming for 45 years and have done consulting and know the first rule is that "Users lie about no changes"; however in this case there ARE no changes to the code. The program wants to rename the data bases so that Input.mdb becomes Input_Old.mdb and Output.mdb becomes Input.mdb. With the control file (Output.ldb) hanging around, the Rename causes an exception. It is [almost] always the Output.ldb file that is still around implying that Output.MDB is still open...
I have taken the code apart line by line; there is only one open and close per database. There are closes within Catch paragraphs. But, there is only one .Open per database.
I've tried a variety of loops testing for the .ldb to go away, but this usually just results in the program running for a very long time doing nothing. When the program is terminated thru its main form's Exit button, the .ldb files go away almost immediately. I can watch the history of file creation, etc. in Windows Explorer as the program runs.
Has anyone experienced this "feature"? If so have you figured out how to solve it?
Charles Wolfe
C. Wolfe Software Engineering
|
|
|
|
|
I've seen this a few times before with other files on windows system. (Windows Server 2003) If I had to guess, the OS is doing some caching or something and the operation is not finished. My solution to this was to use a Try-Catch block and sleep for a few seconds before trying to access the file again. I put a counter in the loop so that if it tries more than 100 times, it finally aborts the operation. Not the best solution, but at least my program no longer crashes because Windows didn't finish renaming the file.
I'm an old VAX/VMS guy and the crap you have to deal with Windows is just awful. (getting off my soapbox now ...)
Give the Try-catch loop thing a try and see if it works for you.
|
|
|
|
|
Maybe, just maybe, your newly created/modified file is in use by another program, e.g. an anti-virus or an indexer (such as Google Desktop Search). What you could do is provide a loop that tries 5 times, with 1 second interval. It is what Windows Explorer does when you tell it to delete a file!
|
|
|
|
|
Hello
I had a very similar problem with an Access database not closing in a VB.NET application. I tried various things like waiting for 5 seconds, a loop retrying every few seconds, adding "OLE DB Services=-4" to the connection string. Nothing worked reliably until I added these two lines after all the database close statements:
GC.Collect()
GC.WaitForPendingFinalizers()
I hope this helps.
Marek
|
|
|
|
|
dear all
how to use compare function, the following is the example code for reading input bit
Dim iShift As Double, I As Double
iShift = 1
For I = 0 To 7
Compare = Int(InputByte And iShift)
If Compare = iShift Then 'Bit Turn OFF
AMD_GalilInputAxisBit(I) = 1
AMD_GalilInputBit(I) = 1
'DigitalIO.Label2(I).BackColor = vbRed
Else
AMD_GalilInputAxisBit(I) = 0 'Bit Turn ON
AMD_GalilInputBit(I) = 0
'DigitalIO.Label2(I).BackColor = vbGreen
End If
iShift = iShift * 2
Next I
|
|
|
|
|
What are you talking about? You're not using a Compare method or function at all in this code. All you're doing is comparing a numeric value to another one.
|
|
|
|
|
Hi,
seems acceptable; here are a few remarks:
1.
when manipulating bits, make sure your variables are integers, so don't use double.
2.
while your comparison to iShift is OK, you could as well test for zero.
3.
maybe, just maybe, you have your two cases (equal and not equal) swapped.
This would be my style (assuming InputByte is an integer too):
Dim I As Integer
Dim iShift As Integer = 1
For I = 0 To 7
If (InputByte And iShift)= 0 Then 'Bit Turn OFF
AMD_GalilInputAxisBit(I) = 0
AMD_GalilInputBit(I) = 0
Else 'Bit Turn ON
AMD_GalilInputAxisBit(I) = 1
AMD_GalilInputBit(I) = 1
End If
iShift = iShift + iShift
Next I
|
|
|
|
|
I want store a string in byte array in hex format.How can I do this.
Actually I want to store an IP address like 165.8.98.76 in byte array.
I am using Hex() method to convert each no.
like changing 165 to its hex no.
Then chnage 8 to 8.
and so on.
But Now how can i store this in byte array.
Problem-
When I convert a no. to hex.Suppose 35 in decimal to 23 in hex.
and when i use
BIp = StrConv(strIp, vbFromUnicode)
Then it stores each digit in 1 byte.
Suppose 172= AC in hex the above method store 'A' in 1 byte and 'C' in 2 byte.
How can I store IP Address in Byte array.
Thanks in adv.
|
|
|
|
|
You definiately do not screw around with the Hex function to do this.
Have you seen the System.Net.IpAddress class, and it's GetAddressBytes method? You might even look at its HostToMetworkOrder and NetworkToHostOrder methods, depending on what you're doing with the byte version of the address.
|
|
|
|
|
I am using a winsock control in my app. which create UDP socket.When I send the data using below code-
Dim sendStr As String
sendStr = "hello"
wsClient.SendData sendStr
Then on server side it shows a string of symbols.
But when I send data as-
wsClient.SendData "Hello"
Then on server side it shows "Hello".
What is the problem with first method.
|
|
|
|
|
There is no problem with that code. The two snippets are identical.
The problem would have to be somewhere else, or this isn't the exact code you're using.
Also, are you saying that you're using the old Winsock control, or are you using the socket classes in System.Net?
|
|
|
|
|
Here is what I have so far...
Private WithEvents CurrentDocument As HtmlDocument
Dim MousePoint As Point
Dim Ele As HtmlElement
Private Sub OpenLinkInNewWindowToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenLinkInNewWindowToolStripMenuItem.Click
Dim FirstForm As New Form1
FirstForm.Show()
End Sub
Private Sub OpenLinkInNewTabToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenLinkInNewTabToolStripMenuItem.Click
Dim Browser As New WebBrowser
Clipboard.SetText(Ele.GetAttribute("href"))
TabControl1.TabPages.Add("New Tab")
TabControl1.SelectTab(Int)
Browser.Name = "Web Browser"
Browser.Dock = DockStyle.Fill
TabControl1.SelectedTab.Controls.Add(Browser)
AddHandler Browser.ProgressChanged, AddressOf Loading
AddHandler Browser.DocumentCompleted, AddressOf Done
Int = Int + 1
Browser.IsWebBrowserContextMenuEnabled = False
Browser.ContextMenuStrip = CMenuMain
Me.TabControl1.SelectedTab.Controls.Add(Browser)
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(Clipboard.GetText)
End Sub
Private Sub CopyLinkLocationToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CopyLinkLocationToolStripMenuItem.Click
Clipboard.SetText(Ele.GetAttribute("href"))
End Sub
Private Sub ViewImageToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ViewImageToolStripMenuItem.Click
Dim Browser As New WebBrowser
Clipboard.SetText(Ele.GetAttribute("src"))
TabControl1.TabPages.Add("New Tab")
TabControl1.SelectTab(Int)
Browser.Name = "Web Browser"
Browser.Dock = DockStyle.Fill
TabControl1.SelectedTab.Controls.Add(Browser)
AddHandler Browser.ProgressChanged, AddressOf Loading
AddHandler Browser.DocumentCompleted, AddressOf Done
Int = Int + 1
Browser.IsWebBrowserContextMenuEnabled = False
Browser.ContextMenuStrip = CMenuMain
Me.TabControl1.SelectedTab.Controls.Add(Browser)
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(Clipboard.GetText)
End Sub
Private Sub CopyImageLocationToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CopyImageLocationToolStripMenuItem.Click
Clipboard.SetText(Ele.GetAttribute("src"))
End Sub
Private Sub SaveImageToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveImageToolStripMenuItem.Click
SaveFileDialog2.ShowDialog()
End Sub
I am working on getting the Open Link in New Window, Open Link in New Tab, Copy Link Location, View Image, and Copy Image Location options. How Would I change my code to get them to work?
I used this page to get some of the code Advanced Web Browser Context Menu Tutorial. I did not add certain parts, because they too would not work. They included these...
-------------------------------------------
Now double click your webbrowser, and go to the Navigated event of the webbrowser. Add this code:
CurrentDocument = Browser.Document
This code tells the CurrentDocument HtmlDocument which we just declared to always be the same as the Webbrowser document.
Next go to the Currentdocument.MouseMove event. Add this code:
MousePoint = New Point(e.MousePosition.X, e.MousePosition.Y)
This tells the program to change the record where the mouse is on the document (so it knows where to get the element that the contextmenu has been shown over).
Now, go to the CMenuMain.Opening event, and add this code:
ele = Currentdocument.GetElementFromPoint(MousePoint)
If ele.TagName = "A" Then
OpenLinkInNewWindowToolStripMenuItem.Visible = True
OpenLinkInNewTabToolStripMenuItem.Visible = True
CopyLinkLocationToolStripMenuItem.Visible = True
ToolStripMenuItem29.Visible = True
Else
OpenLinkInNewWindowToolStripMenuItem.Visible = False
OpenLinkInNewTabToolStripMenuItem.Visible = False
CopyLinkLocationToolStripMenuItem.Visible = False
ToolStripMenuItem29.Visible = False
End If
If ele.TagName = "IMG" Then
ViewImageToolStripMenuItem.Visible = True
CopyImageLocationToolStripMenuItem.Visible = True
SaveImageToolStripMenuItem.Visible = True
ToolStripSeparator19.Visible = True
Else
ViewImageToolStripMenuItem.Visible = False
CopyImageLocationToolStripMenuItem.Visible = False
SaveImageToolStripMenuItem.Visible = False
ToolStripSeparator19.Visible = False
End If
This is where ele and MousePoint come into action. This code makes ele (the HtmlElement, say an image, a link or a button) whatever HtmlElement the mouse is over on the webbrowser, because we made MousePoint wherever the mouse was on the document when it moved.
-------------------------------------------
I'd like to implement that code into the project as well, thanks in advance!!
|
|
|
|