|
I have a basic form with one button and two textbox's txtusername and txtpassword. What dose the code look like to make this work. "O" yea and how do I verify with a picturebox that the connection has been made?
|
|
|
|
|
If I create a Structure and assign an array to it, is there any way to search for the value in an array and return the structure name? I am sure that the name is associated with the array index but I don't know what property it has.
As a simple example...
Public Structure MyStructure
dim A as String
dim B as string
dim C as string
End Structure
Public myArray(0) As MyStructure
myArray(0).A = "Bill"
myArray(0).B = "Tom"
myArray(0).C = "Joe"
Is there a way to loop through the array to find the value "Bill" and return
whether it is contained in A, B or C?
I am actually trying to populate an array with values from fields on a form.
The field names are the same as the Structure names. So I could set the values
by comparing the names.
Thanks
Dennis
|
|
|
|
|
Hello I am writting a scheduling program for my work and am almost finished but am stuck at a very important part. I am a new programmer so if anyone could help I would greatly appreciate it!!!
I have made a simple DB in MS Access with fields such as:
First Name, Last Name, Address, Phone, Repair Type, Repair Time, Repair Date, Repair Tech
In my vb.net program I can type in all the customers info like names, phone and address, also can type in the repair time and date and repair tech. Then it sends that information to my DB.
What I am stuck on is I need to be able to open a different form, type in the date and the type of repair it is (repair or replacement) and search my DB for these strings. Then the most important part is I need to take those listings and print them in a neat organized format all on one page so my repair techs can print out there schedules for that day. I need to keep the different records in my DB grouped when I print them into my form, if that makes sense. I have spent hours and hours searching high and low for anything on how to do this and have found nothing. If you can please help me you can also contact me through email. I would GREATLY appreciate any help!!!!!!!! Thank you in advance.
Jon
myjunkmail94@hotmail.com
|
|
|
|
|
i'm not sure what you are asking if you are just wanting to add a print dialog to your form so it will print your adjusted data i'm just not sure what exactly because i connnot see your form and to save myself from sounding too stupied cuz i am also new at this can you not do a StreamReader on a form 2 with a print dialog here is a site i found with data base code samples
http://www.microsoft.com/downloads/details.aspx?familyid=87951cb9-5aeb-4f46-9bf0-2b3e3664be77&displaylang=en[^]
damn that is a long site address copy and past that and try those samples see if u can get what you are looking for
|
|
|
|
|
Sounds like you need a report to print based on data selected from the database. Do you know how to write database queries (SELECT somehting FROM TABLE)
<br />
<br />
SELECT First Name, <br />
Last Name, <br />
Address, <br />
Phone, <br />
Repair_Type, <br />
Repair_Time, <br />
Repair_Date, <br />
Repair_Tech<br />
FROM <br />
TABLE_NAME<br />
WHERE <br />
Repair_Type = (repair or replacement)<br />
AND <br />
Repair_Tech = Tech_Name<br />
The rest depends on what method you are using to execute the sql are you using a dataadapter, sqldatareader, etc... Loop thru the records and write them to a file or a richtext box then print it.
I suggest an ADO.NET or ODBC.NET book
|
|
|
|
|
hDevice = SetupDiGetClassDevs(pGuid,NULL,NULL,DIGCF_PRESENT);
' VB fials every time with hDevice = -1 = INVALID_HANDLE_VALUE
'and GetLastError() = 0 = ERROR_SUCCESS
hDevice = SetupDiGetClassDevs(ClassGuid, 0&, 0&, DIGCF_PRESENT)
Both pGuid and ClassGuid contain the exact same GUID data.
Does anyone have any ideas why this 'C' function would fail when called from VB?
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
Without seeing the Declaration of the function and the types of your variables, there's nothing we can do to help you. 99.99999999999999999% of library function call failures are because the function declarations are wrong or parameters are not passed correctly.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks for the reply! I am afraid I did not see this yesterday when I was at work, so I'll have to post the code on monday.
I found a program on the web called ApiViewer 2004 (ApiViewer.exe) that produced the exact same declarations I wrote by hand. With the exception of SetupDiGetClassDevs, which the viewer produced incorrectly. The declartion produced by the ApiViewer 2004, specified a sub without any return value (I corrected this and informed them of the error).
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
Here is the complete module where the call is failing.
Note: Since this does not support Win95, I have just wraped up some C code (that does) in an ActiveX control via VC++ ATL 3.0.
I would still appreciate knowing why this code is failing.
'EnumSerialPorts.bas - 1/26/2005 - John R. Shaw
Option Explicit
Private Const RegDisposition_OpenExisting As Long = &H1 'open key only if exists
Private Const CM_REGISTRY_HARDWARE As Long = &H0
Private Const KEY_QUERY_VALUE = &H1
Type Guid
Data1 As Long 'unsigned long Data1;
Data2 As Integer 'unsigned short Data2;
Data3 As Integer 'unsigned short Data3;
Data4(0 To 7) As Byte 'unsigned char Data4[ 8 ];
End Type
Type SP_DEVINFO_DATA
cbSize As Long 'DWORD cbSize;
ClassGuid As Guid 'GUID ClassGuid;
DevInst As Long 'DWORD DevInst;// DEVINST handle
Reserved As Long 'DWORD Reserved;
End Type
'Constants copied from API Viewer
Public Const INVALID_HANDLE_VALUE = -1
Public Const ERROR_SUCCESS = 0&
'Registry access function copied from API Viewer
Private Declare Function RegCloseKey Lib "advapi32.dll" ( _
ByVal hKey As Long) As Long
Private Declare Function RegQueryValueEx Lib "advapi32.dll" _
Alias "RegQueryValueExA" ( _
ByVal hKey As Long, _
ByVal lpValueName As String, _
ByVal lpReserved As Long, _
lpType As Long, _
lpData As Any, _
lpcbData As Long) As Long
' Note that if you declare the lpData parameter as String, _
' you must pass it By Value.
' Flags controlling what is included in the device information set built
' by SetupDiGetClassDevs
Public Const DIGCF_DEFAULT As Long = &H1 ' only valid with DIGCF_DEVICEINTERFACE
Public Const DIGCF_PRESENT As Long = &H2
Public Const DIGCF_ALLCLASSES As Long = &H4
Public Const DIGCF_PROFILE As Long = &H8
Public Const DIGCF_DEVICEINTERFACE As Long = &H10
'Setup API functions copied from "ApiViewer 2004" from ActiveVB.de
Private Declare Function SetupDiClassGuidsFromName Lib "setupapi.dll" _
Alias "SetupDiClassGuidsFromNameA" ( _
ByVal ClassName As String, _
ByVal ClassGuidList As Long, _
ByVal ClassGuidListSize As Long, _
ByRef RequiredSize As Long) As Long
Private Declare Function SetupDiDestroyDeviceInfoList Lib "setupapi.dll" ( _
ByRef DeviceInfoSet As Long) As Long
Private Declare Function SetupDiEnumDeviceInfo Lib "setupapi.dll" ( _
ByRef DeviceInfoSet As Long, _
ByVal MemberIndex As Long, _
ByRef DeviceInfoData As SP_DEVINFO_DATA) As Long
Private Declare Function SetupDiGetClassDevs Lib "setupapi.dll" _
Alias "SetupDiGetClassDevsA" ( _
ByRef ClassGuid As Guid, _
ByVal Enumerator As String, _
ByVal hwndParent As Long, _
ByVal Flags As Long) As Long
'Configuration management API functions entered by hand
Private Declare Function OpenDevNodeKey Lib "cfgmgr32.dll" _
Alias "CM_Open_DevNode_Key" ( _
ByVal dnDevNode As Long, _
ByVal samDesired As Long, _
ByVal hardwareProfile As Long, _
ByVal regDisposition As Long, _
phkDevice As Long, _
ByVal Flags As Long) As Long
'Serial port enumeration function
Public Function EnumSerialPorts() As String
Dim bRes As Byte
'Get ready to enumerate serialports
Dim RequiredSize As Long: RequiredSize = 1
Dim ClassGuid As Guid
bRes = SetupDiClassGuidsFromName("Ports", VarPtr(ClassGuid), 1, RequiredSize)
If bRes = 0 Or RequiredSize <> 1 Then
Exit Function 'I am assuming only 1 class exists for ports
End If
Debug.Print "Ports Guid = {" + _
Format(Hex(ClassGuid.Data1), "00000000") + "-" + _
Format(Hex(ClassGuid.Data2), , "00000000") + "-" + _
Format(Hex(ClassGuid.Data3), , "00000000") + "-" + _
Format(Hex(ClassGuid.Data4(0)), "00") + _
Format(Hex(ClassGuid.Data4(1)), "00") + "-" + _
Format(Hex(ClassGuid.Data4(2)), "00") + _
Format(Hex(ClassGuid.Data4(3)), "00") + _
Format(Hex(ClassGuid.Data4(4)), "00") + _
Format(Hex(ClassGuid.Data4(5)), "00") + _
Format(Hex(ClassGuid.Data4(6)), "00") + _
Format(Hex(ClassGuid.Data4(7)), "00") + _
"}"
Dim hDevice As Long
hDevice = SetupDiGetClassDevs(ClassGuid, 0, 0, DIGCF_PRESENT)
If hDevice = INVALID_HANDLE_VALUE Then Exit Function
Dim DeviceInfoData As SP_DEVINFO_DATA
DeviceInfoData.cbSize = Len(DeviceInfoData)
Dim lRes As Long
Dim hKeyDevice As Long
Dim cbData As Long: cbData = 16
Dim devName As String * 16
Dim MemberIndex As Long
For MemberIndex = 0 To 255 'This is more than resonable limit
bRes = SetupDiEnumDeviceInfo(hDevice, MemberIndex, DeviceInfoData)
If Not bRes Then
SetupDiDestroyDeviceInfoList (hDevice)
Exit Function
End If
lRes = OpenDevNodeKey(DeviceInfoData.DevInst, KEY_QUERY_VALUE, 0, _
RegDisposition_OpenExisting, hKeyDevice, CM_REGISTRY_HARDWARE)
If lRes <> ERROR_SUCCESS Then
SetupDiDestroyDeviceInfoList (hDevice)
Exit Function
End If
lRes = RegQueryValueEx(hKeyDevice, "portname", 0&, 0&, devName, cbData)
RegCloseKey (hKeyDevice)
If lRes <> ERROR_SUCCESS Then
SetupDiDestroyDeviceInfoList (hDevice)
Exit Function
End If
If Mid(devName, 1, 3) = "com" Then
If Int(Val(Mid(devName, 4))) > 0 Then
If EnumSerialPorts <> Empty Then
EnumSerialPorts = EnumSerialPorts + " "
End If
EnumSerialPorts = EnumSerialPorts + devName
End If
End If
Next MemberIndex
End Function
Thanks!
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
Hi i am trying to create a new toolbar for IE to change proxies, i keep getting an error that says: "Attribute Specifier is not a complete Statement. Use a line continuation to apply the attribute to the following statement." this is my code:
<Guid ("E08554F2-3571-45e5-9A18-13D4DFCCDD61")> _
' Create new BandObject
<BandObject("IE Proxy Manager, CB: Omar Becerra", BandObjectStyle.Horizontal, _
BandObjectStyle.ExplorerToolbar, HelpText = "IE Proxy Manager to change Disney Proxies")> _
Can any one please help?
|
|
|
|
|
I think you're looking for something like this:
<Guid("E08554F2-3571-45e5-9A18-13D4DFCCDD61"), _
BandObject("IE Proxy Manager, CB: Omar Becerra", BandObjectStyle.Horizontal, _
BandObjectStyle.ExplorerToolbar, HelpText = "IE Proxy Manager to change Disney Proxies")> _
...rest of code here...
But, this assumes, of course, that you've already defined the attribute class BandObject and the corresponding enum BandObjectStyle , since neither is part of the .NET Framework.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I see where you got this now... You goofed on the number of parameters BandObject takes. You gave it 4 parameters and the attribute class only takes 3:
<Guid("E08554F2-3571-45e5-9A18-13D4DFCCDD61"), _
BandObject("IE Proxy Manager, CB: Omar Becerra", BandObjectStyle.Horizontal + _
BandObjectStyle.ExplorerToolbar, HelpText = "IE Proxy Manager to change Disney Proxies")> _
...rest of code here...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I have everything declared, everything is fine, but i still keep getting that same error, there is that blue line underneath the >
|
|
|
|
|
You missed something. Without seeing the EXACT code (copy and paste) we can't tell you what's wrong.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi Everyone!
I'm new to VB.Net, but I've got this project that requires a DropDown Selection Box to load one item into a submitButton which passes the item to a textBox as a string. Does anyone know how this is done?
Really need your suggestions.
DuckPlucker
|
|
|
|
|
Are you talking about a web form or a windows form? Also, what do you mean by "load one item into a submitButton"? Buttons don't contain anything, so I don't know what you mean by this.
If all your looking to do is put text into a textbox on a Windows Form, then handling the SelectIndexChanged event of the ComboBox should work:
TextBox1.Text = ComboBox1.SelectedItem.ToString()
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hello,
I'd like to know if anyone has had any experience with calling DLLS created via VB 6.0 in a C application. The reason I ask is because we are using an Human Machine Interface application which uses a form of C (Called C-Scripting ... an equvalent to VBA) and we would like to use some custom database access dlls that we've already created in C. Do the DLLs have to be rebuilt in a specific way. The equivalent DLL call in VB would be :
Dim x As prjTPMCount.clsTPMCount
Dim vResultDLL As Variant
Set x = New prjTPMCount.clsTPMCount
vResultDLL = x.fctPLC_TPMCount
MsgBox vResultDLL(1, 1), vbInformation, "DLL 1 Output Connection Status"
MsgBox vResultDLL(2, 1), vbInformation, "DLL 2 Output Connection Status"
In C-Script, I tried to declare the .DLL as follows :
#pragma code("RACCTPMCount.dll")
int* fctPLC_TPMCount();
#pragma code()
int* iResult;
iResult = fctPLC_TPMCount();
My error code says it is unable to find the function "fctPLC_TPMCount" in RACCTPMCount.dll
Any help would be greatly appreciated
Cheers
Rusty
|
|
|
|
|
There is no way to "rebuild" a VB DLL in any manner other than the way VB compiles it.
VB DLLs are always created as COM dlls. They don't have any mechanism to export function calls like a C DLL. The only way you can call a VB dll is via the COM interfaces.
You cannot access the VB DLL from C because COM implies classes and interface definitions, and C does not support the concept of a class at all.
Your only option (other than rewrite the VB code in your C language) is to write a C++ proxy component that can call the VB DLL and also exports "C" style function calls that your main application can call.
You can write components in C++ that can interact with a VB DLL using either pure COM programming or using ATL/COM.
Neither is a particularly trivial task.
Unless it involves tons of code I would probably just rewrite the VB code.
If that is not an option, unless you already know ATL/COM or "straight" COM programming in C++ it could take you quite a while to get it all to work.
If you need it quick and cheap, and you don't anticipate any changes once it's done and working, I would suggest farming it out on something like Rentacoder. That's fine for something that you basically just need to get working.
But just be aware that 9 times out of 10 (at least) code that comes out of India, etc. is not going to be commented, maintainable, or for that matter even decipherable for the most part.
I know there are exceptions, and some offshore code is good quality, but it is the exception. Sorry if I stepped on anyone toes, but it's pretty much true.
Robert
|
|
|
|
|
int _stdcall CreateTemp(BYTE* pImageData,int nImageWidth,int nImageHeight,BYTE * pTemplate,int &nSize)
When I run the application , error happened which says the memory is protected.
|
|
|
|
|
I have a VB.Net windows app that retrieves data from 3 different tables. The SQL command uses a 3 table join. The results from the query is filled into a datatable and later populated into a combobox.
The SQL uses the values from a date field inside a text field, for example, 01-15-2005. So, each time I submit the subroutine it executes the SQL command and VB.Net code to retrieve the required data. The date field changes according to the user’s needs.
There’s no consistency when the error pops up.
The error message I’m getting when it executes, da.Fill(dataTable), “There’s no row at position 0”,. The information I’m on the stack track is as follow: Calling SQLDisconnect --- OleDB UnInitialize not called!!!
Connection Object destroyed
If I copy the sql into a sql query tool it does retrieve the required data according to the date field.
Here’s a sample of the subroutine:
cmdQueryINVOICE = _
"SELECT PAYITEM.TRANSACT_NUMBER, " _
& "PAYITEM.ACCOUNT_NUMBER, " _
& "PAYITEM.PAY_DATE, " _
& "LSEINVH.INVOICE_NUMBER " _
& "FROM LSEINVH, PAYITEM, TRANSHDR " _
& "WHERE " _
& " LSEINVH.INVOICE_NUMBER > '" & 75000 _
& "' AND LSEINVH.STATUS <> '" & sStatus _
& "' AND LSEINVH.INVOICE_NUMBER = TRANSHDR.INVOICE_NUMBER " _
& " AND PAYITEM.PAY_DATE > '" & InvoiceDates.StartDate _
& "' AND PAYITEM.PAY_DATE < '" & InvoiceDates.EndDate _
& "' AND PAYITEM.COMPANY = '" & sCompany _
& "' AND PAYITEM.TRANSACT_NUMBER = TRANSHDR.TRANS_NUMBER order by PAYITEM.PAY_DATE desc "
Dim sqlQuery As OleDbCommand = connDf.CreateCommand
Dim dtInvDate As New DataTable()
Dim iInvCnt, x As Integer
Dim sUnitQuery As String
Dim daInv As New OleDbDataAdapter()
Try
daInv = New OleDbDataAdapter(cmdQueryINVOICE, connDf)
daInv.Fill(dtInvDate)
Dim LoopRow As Data.DataRow
Dim test As String = dtInvDate.Rows.Item(0).ToString
For Each LoopRow In dtInvDate.Rows
cboInvoice.Items.Add(LoopRow.Item("INVOICE_NUMBER").ToString + " " + LoopRow.Item("PAY_DATE"))
Next
Catch e As Exception
Dim errMsg As String = e.Message
Finally
connDf.Close()
End Try
Thanks, any help would be grateful.
|
|
|
|
|
I don't know if this will make any difference, but you would be better off using the SQLDataAdaptor, SQLCommand and SQLConnection objects to access SQL. They work better.
If you have knowledge, let others light their candles at it.
Margaret Fuller (1810 - 1850)
|
|
|
|
|
Thanks for your reply. I'll using OleDb is because I'm connecting to a dataflex table and not SQL Server. I did find a solution to the problem. Thanks again.
|
|
|
|
|
I assume connDF is valid somewhere else And you are not even using sqlQuery.
I believe that the table needs to be part of a dataset for the adapter to fill.
<br />
Dim ds As new DataSet<br />
Dim dt As DataTable<br />
dt.TableName="InvDate"<br />
ds.Tables.Add(dt)<br />
<br />
Dim connection as string = "Whatever your connection string"<br />
Dim conn As New OleDbConnection(connection)<br />
Dim adapter As New OleDbDataAdapter()<br />
adapter.SelectCommand = new OleDbCommand(CmdqueryInvoice, conn)<br />
adapter.Fill(ds.tables("InvDate"))<br />
<br />
Dim LoopRow As Data.DataRow<br />
<br />
For Each LoopRow In ds.tables("InvDate")Rows<br />
.....<br />
Next<br />
If that does not work look at how the dataadapter processes joins. It may be the adapter will create the joined tables in the dataset but it will not automatically set the primary keys for the relationship. You may need to create the table schemas in the dataset then fill it. too much trouble? return a datareader and create your own columns and insert the data. Or just loop thru the reader.
|
|
|
|
|
Thanks for your suggestion. I tried your recommendation, but I was getting the same results. I decided to set the date range higher in the sql query and placing the larger results into the dataset. It takes longer to load, but the overall results are much better. Thanks again for your suggestion.
|
|
|
|
|
Hi i am trying to create a new toolbar for IE to change proxies, i keep getting an error that says: "Attribute Specifier is not a complete Statement. Use a line continuation to apply the attribute to the following statement." this is my code:
<guid ("e08554f2-3571-45e5-9a18-13d4dfccdd61")=""> _
' Create new BandObject
<bandobject("ie proxy="" manager,="" cb:="" omar="" ",="" bandobjectstyle.horizontal,="" _
="" bandobjectstyle.explorertoolbar,="" helptext="IE Proxy Manager to change Proxies" )=""> _
how could i fix this?
|
|
|
|
|