|
In my program I am cycling through port numbers starting with COM1 all the way to COM100 to check if my device is hooked up to a com port. I dont think there are 100 Com ports on the pc but I am not sure. Is there a reasonable number that I should cycle up to?
|
|
|
|
|
Hi,
COM ports aren't always called "COMdd", for some of them you can freely choose the name (this requires a driver that allows for it, often the case with USB-to-RS232C cables).
Assuming you are using .NET, I suggest you have a look at SerialPort.GetPortNames().
If you are still considering ancient VB code, you would need help from some Win32 functions, maybe EnumDevices. Have a look here[^] (it is C++ code) and/or search CodeProject or google.
|
|
|
|
|
Hi,
I need to connect to access db on 64bit WinXP machine. I've read that jet provider is not available on 64 machines...., but the exact code runs perfectly in VB6 on the same machine but i cant get it to work in VB.net
here is the .Net code that stops at dbConn.Open() and says {"Provider cannot be found. It may not be properly installed."}
Private Sub FRMOption_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated
Dim SQL_STR As String
Dim ConnSTR As String
Dim dbConn As ADODB.Connection
Dim rs As ADODB.Recordset
SQL_STR = "select * from TBL_Favorits where FAV_Delete_Bol=false order by FAV_Used_Bol,FAV_Order_Txt,FAV_Oper_Txt"
ConnSTR = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & My.Application.Info.DirectoryPath & "\localFTC.mdb;"
dbConn = New ADODB.Connection
rs = New ADODB.Recordset
dbConn.Mode = ADODB.ConnectModeEnum.adModeRead
dbConn.ConnectionString = ConnSTR
dbConn.Open()
rs.Open(SQL_STR, dbConn, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic)
If Not rs.BOF Then
While Not rs.EOF
ComboBox1.Items.Add(rs.Fields("FAV_Order_Txt").Value & " " & rs.Fields("FAV_Oper_Txt").Value)
rs.MoveNext()
End While
End If
rs.Close()
dbConn.Close()
End Sub
Thanks
Arash
|
|
|
|
|
I think this is what you are missing:
Go to Project Properties
Click on the Compile Tab
Select "All Configurations" in the Configuration drop down
Click the Advanced Compile Options button
In the Advanced Compiler Settings form, set the Target CPU to x86
This compiles the application as a 32 bit program, and when running on a 64 bit machine it should be able to find the provider.
|
|
|
|
|
That was it. thanks for the help now i can simply use the data binding instead of all that.
|
|
|
|
|
The reason why this works is because, like has been stated before, there are no OLEDB drivers in 64-bit. You cannot run both 64 and 32-bit code in the same process. So, since your app was 64-bit, you couldn't use the 32-bit OLEDB drivers to get at the database. That's why your code works when forced to compile as a 32-bit app.
|
|
|
|
|
hey there
I got a visual basic 2008 express version
but the 'Target CPU' option isn't where you said it should be..
anybody know what could be the cause of that?
Thanks
Empathies
|
|
|
|
|
That's because it isn't there in the Express Editions. There is no 64-bit compiler support in the Express Editions, therefore you won't get the option to limit the compiler to 32-bit only code. It's already 32-bit only.
|
|
|
|
|
|
I have same issue but the advanced tab is not available it is there but disabled?
|
|
|
|
|
What version of Visual Studio are you using? Perhaps that feature is not available in the Express version?
|
|
|
|
|
Sorry for the vague title, I guess creativity in describing issues is not my forte.
Brief summary, I have made a Menu control for an application that functions as intended. The menu control has a hierarchy of other controls which is somewhat to complex, but has a great deal of controls. I receive a data table which my menu uses as a data source to add controls to compose the menu of the application, however it takes a great deal of time to construct and there is an issue with drawing. All my controls are in a single FlowLayoutPanel within my Menu control.
The issue is, the order in which I add controls within the FlowLayoutPanel where respected when the FlowLayoutPanel was added during design time. For the issues stated above, I moved my FlowLayoutPanel to be created during run-time, in hopes that my drawing issues will go away if I add all my controls to the FlowLayoutPanel, and then to the Menu control.
For some reason, now the respect in which controls where added to the FlowLayoutPanel are no longer respected, so the ordering of controls are lost. I've debugged all my loops and recursion methods and they are added in the correct order, but the Controls.Item(i to Max) do not list them in that same order.
Is there a reason why, if no algorithms to add the controls where changed, why the FlowLayoutPanel would incorrectly order controls if it placed during design-time over run-time? Why would this behavior change during design time?
If any clarification is needed, please ask.
An example of code is posted below...
first instance of adding a control to the ControlArea of type System.Windows.Forms.ControlLayoutPanel
Me.ControlArea.Controls.Add(MenuButton1)
AddHandler MenuButton1.Click, AddressOf MenuButtonClicked
HeaderLayoutPanel = New System.Windows.Forms.FlowLayoutPanel
HeaderLayoutPanel.Anchor = Windows.Forms.AnchorStyles.Left And Windows.Forms.AnchorStyles.Top And Windows.Forms.AnchorStyles.Right
HeaderLayoutPanel.Width = Me.Width
HeaderLayoutPanel.Height = 0
HeaderLayoutPanel.Margin = New System.Windows.Forms.Padding(0, 0, 0, 0)
HeaderLayoutPanel.Tag = MenuButton1.Tag
second instance
Me.ControlArea.Controls.Add(HeaderLayoutPanel)
Then I have a loop to add a MenuButton, and immediately underneath another FlowLayoutPanel which holds other controls etc.
But in the FlowLayoutPanel, it orders all MenuButtons followed by all FlowLayoutPanels, not respecting the order they where added in.
Any insight is appreciated.
Thank you for the time and the read.
|
|
|
|
|
Hi EliottA,
I have no experience with FlowLayoutPanel, but I have a gut feeling, if I were a FlowLayoutPanel, I wouldn't like my height being set to zero...
|
|
|
|
|
The height is sized accordingly, sorry for leaving the detail out.
All the controls are shown, just not in the order that they where added. The general order is MenuButton followed by a FlowLayoutPanel who's visibility is set to false. When you click that MenuButton, the FlowLayoutPanel's visibility is toggled.
The issue is, despite the way I've added my controls, the z-order index appears to be out of whack and the FlowLayoutPanel is reordering them by itself (See similar issue[^]), also been reported to Microsoft Bug 434674 here[^].
Thanks for the quick reply Luc, it is appreciated.
|
|
|
|
|
The first link you provided makes it smell like a bug indeed. You could study the matter using reflector...
|
|
|
|
|
On my own time, maybe.
A quick and dirty workaround was to make the FlowLayoutPanel visible while I was populating it while it's parent container (the Menu control itself) was invisible. Then swap each and order was preserved nicely. On company time, this will do for now but I'm interested to go through it on my own time using reflector to see why this odd behavior exists.
Thanks again Luc.
|
|
|
|
|
I've been trying to get a picture of a window by getting it's device context and blitting it onto a graphics object. This all works fine and I can see the image on a picturebox, but some weird things happen sometimes.
Sometimes I get windows without a title bar, and it seems to not like maximized windows very much. Also, for some reason, once it has gotten the image for a window, whatever was behind the window's glass the first time, will stay there no matter what until I restart it (my program).
I've properly released the DC afterwards so I don't know what could be causing this.
Have you tried the Krypton Toolkit? http://www.componentfactory.com/free-windows-forms-controls.php
|
|
|
|
|
Hey,
I need to access the CByte function from C#
I've referenced the Microsoft.VisualBasic .Net Component but I can't figure out how to access the CByte function.
I understand doing this is very strange, I have my strange reasons. Properly converting it to c# is plan b, at the moment if it's easy to access the CByte function i'd much rather do that.
Thank you
|
|
|
|
|
I suppose you could just make a quick 'wrapper' dll in visual basic that encapsulates the function for you and reference that in your program.
Have you tried the Krypton Toolkit? http://www.componentfactory.com/free-windows-forms-controls.php
|
|
|
|
|
I don't think you can. I would imagine the function would be something like this in C# - or you can modify this to work as required:
public static byte CByte(object expression)
{
byte result = 0;
if (expression is IConvertible)
{
try
{
result = Convert.ToByte(expression);
}
catch
{
}
}
return result;
}
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
What's wrong with using Convert.ToByte()???
No jumping through hoops, no VisualBasic namespace, just a conversion...
|
|
|
|
|
This is the best solution.
Note that "CByte" and the other related ones (CInt, CStr, etc.) are operators in VB and are not methods in any library, so you have to use something else, such as Convert.ToByte as recommended by Dave K.
David Anton
http://www.tangiblesoftwaresolutions.com
Convert VB to C#, C++, or Java
Convert C# to VB, C++, or Java
Convert C++ to C#, VB, or Java
Convert Java to C#, C++, or VB
|
|
|
|
|
Hi
Is there any way of capturing a link click event from a DataGridViewLinkCell?
I'm starting to think that this column's only purpose is to underline text...
Anyway, any help is apreciated
Thanks
|
|
|
|
|
Take a look at this answer to a similar problem[^], substitute LinkLabel for CheckBox and use the event of your choice.
I have never used a LinkLabel , so cannot help on that part of it.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi,
im programming a tournament draw system in vb .net, which is an elimination system. i have completed all other modules in this project, now i need to make the draw. As there is an underlying points system, i need to record the byes, which do not score, and wins, which score 1 point.
so, if there are 5 entrants [a,b,c,d,e] in a particular division, the first round would be:
[a,b]
[c,d]
e
where b and c win, and e receives a bye. the second round would be:
b
[c,e]
where b now receives the bye. after this there would be 1 more round; a total of 3 rounds, 2 byes and 4 matches
how can i do this programmatically? i cant find a suitable pattern to follow or any useful info on google
has anyone made something similar? is there some keyword that i should search for?
i do realise that i havent supplied any actual code, but i dont have any to attach that would prove relevant
thanks,
-n
|
|
|
|
|