|
Hello,
I want to make an application which writes and reads the records from a binary file and to search the records according to various parameter of each record from the file efficiently. How could I do this job using VB 2010?
|
|
|
|
|
Binary files to store and retrieve data consistently and efficiently are called "databases". What you are suggesting is writing your own database, which is a cool excercise. If you don't have the time to learn how a database works internally, then you'd best use an existing database-application. Sqlite and SqlCE would use local (binary) files that you can query easily.
Bastard Programmer from Hell
|
|
|
|
|
Hello all,
Whenever I run my program, it gives the error "32-bit processes cannot access the modules of 64-bit processes," since my program is 32-bit and that it reads (basically) every 64-bit processes start-up path, and terminates it or keeps it alive to make sure it's the real program. So how can I build my program in 64-bit.
Simple Thanks and Regards,
Brandon T. H.
Been programming in Visual Basic for 4 years this point forward, and is very good at it (I can even create programs completely on code, without dragging those items from the toolbox). Programming C++ for 1 year so far and the same with C#.
Many of life's failures are people who did not realize how close they were to success when they gave up. - Thomas Edison
modified 3-May-12 8:57am.
|
|
|
|
|
|
lol, ok
Simple Thanks and Regards,
Brandon T. H.
Been programming in Visual Basic for 4 years this point forward, and is very good at it (I can even create programs completely on code, without dragging those items from the toolbox). Programming C++ for 1 year so far and the same with C#.
Many of life's failures are people who did not realize how close they were to success when they gave up. - Thomas Edison
|
|
|
|
|
Thanks bro it helped
Simple Thanks and Regards,
Brandon T. H.
Been programming in Visual Basic for 4 years this point forward, and is very good at it (I can even create programs completely on code, without dragging those items from the toolbox). Programming C++ for 1 year so far and the same with C#.
Many of life's failures are people who did not realize how close they were to success when they gave up. - Thomas Edison
|
|
|
|
|
It's good to combine a joke with being useful! Don't get the chance too often.
Cheers,
Peter
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
Thanks for the advice
Simple Thanks and Regards,
Brandon T. H.
Been programming in Visual Basic for 4 years this point forward, and is very good at it (I can even create programs completely on code, without dragging those items from the toolbox). Programming C++ for 1 year so far and the same with C#.
Many of life's failures are people who did not realize how close they were to success when they gave up. - Thomas Edison
|
|
|
|
|
Imports System.Runtime.InteropServices
Public Class Form1
Public Const MAXPNAMELEN = 32 ' max product name length (including NULL)
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi)> _
Structure MIDIINCAPS 'Structure def copied from win32api.txt
Dim wMid As Int16
Dim wPid As Int16
Dim vVersion As Integer
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=MAXPNAMELEN)> _
Dim szPname As String 'win32api.txt def is String*MAXPNAMELEN
End Structure
Declare Function midiInGetNumDevs Lib "winmm.dll" () As Long
Declare Function midiInGetDevCaps Lib "winmm.dll" Alias "midiInGetDevCapsA" _
(ByVal uDeviceID As Int32, ByVal lpCaps As MIDIINCAPS, ByVal uSize As Int32) As Int32
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim retval As Int32
Dim NumMidiInDevices As Int32
Dim DevCounter As Int32
Dim devicecaps As New MIDIINCAPS
NumMidiInDevices = midiInGetNumDevs()
For DevCounter = 0 To NumMidiInDevices - 1
retval = midiInGetDevCaps(DevCounter, devicecaps, Len(devicecaps)) ' Runtime error msg here
'=======================================================================
'A call to PInvoke function 'MidiInCapTest!MidiInCapTest.Form1::midiInGetDevCaps' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.
'========================================================================
Next DevCounter
End Sub
'============================================================================
'I have tried <VBFixedString(MAXPNAMELEN)> instead of Marshall as, in the sructure plus countless tries at int16, int32 etc for the other parameters in the API call,in a fruitless attempt to outwit the known inconsistencies between winapi32.txt data types & .NET but to no avail.
'Can anyone help
End Class
|
|
|
|
|
The main thing is that the 2nd parameter should be 'ByRef':
Declare Function midiInGetDevCaps Lib "winmm.dll" Alias "midiInGetDevCapsA" (ByVal uDeviceID As Integer, ByRef lpCaps As MIDIINCAPS, ByVal uSize As Integer) As Integer
Public Structure MIDIINCAPS
Dim ManufacturerID As Short
Dim ProductID As Short
Dim DriverVersion As Integer
Dim Label As String
Dim Support As Integer
End Structure
David Anton
Convert between VB, C#, C++, & Java
www.tangiblesoftwaresolutions.com
|
|
|
|
|
You are right, the main thing was to use byref on the 2nd param. I usually copy Api calls directly from win32api.txt but in this case copied it from someone elses downloaded code
Thanks for the assist
Midigeek
|
|
|
|
|
Hi,
This article[^] of mine should help you out for most issues.
Yes it may take some experimenting; however for optimum progress, you should fix issues in this order:
1. The stack problem should be solved through the CallingConvention attribute.
2. The numeric parameters or fields should pose no problem, just make sure you use the managed/unmanaged types with matching sizes.
3. The fixed-length string field takes a MarshalAs with SizeConst (not sure a symbolic constant is acceptable); I expect ByValTStr is right, the doc says:
Used for in-line, fixed-length character arrays that appear within a structure. The character type used with ByValTStr is determined by the System.Runtime.InteropServices.CharSet argument of the System.Runtime.InteropServices.StructLayoutAttribute applied to the containing structure.
Good luck
|
|
|
|
|
See my reply to David Anton's ByRef suggestio which was the only change I made. Thanks for the link to your article which also mentions delegates.
Now that Phase one (identify connected MIDI devices) works I shall code the MidiIn phase....watch this space!
|
|
|
|
|
Hi,
I have two numbers, they are rather large.
So I have
dim A
dim B
A=123456789
B=123456789
I am trying to compare the numbers,
if (A > B) then
code here
else
code here 2
end if
It is not comparing the numbers for some reason and going into the first part of the if statement, which is quite frankly false. I want it to go the second part of the code.
I have tried to cast A and B as cint, that did not work as well.
Any help is appreciated.
|
|
|
|
|
Without seeing your actual code, it's pretty much impossible to tell you what's wrong. From your description, it's possible that you might be comparing strings and not the values they represent.
|
|
|
|
|
you are right on the dot! But how can I make this code compare as numbers? I tried to cast as number and it did not work. I used cint.
|
|
|
|
|
have you tried not to use CInt and dim an integer variable?
|
|
|
|
|
What did I just say about seeing the relevent code??
|
|
|
|
|
It look just like what I mentioned in my intial email.
if (A > B) then
code1
else
code2
end if
I have also tried it this way:
if ((cint(A) > cint(B))
code1
else
code2
end if
|
|
|
|
|
That's only the compare, not the relevant code. What is supply these variables you are comparing???
|
|
|
|
|
Thanks for all your help.
I used CDbl to on the number and it is working.
|
|
|
|
|
Hi guys I have very big question
I have a project on Visual Studio, this project include table SQL data. I notice when I add records or add rows with information . imagine that I add more than 1000 rows full with a lot of names and number. the crazy thing that all these data will be removed once I change a little code or add. I wonder how can I protect my data even I make change code time to time.
|
|
|
|
|
What makes you think that changing the code in your project magically causes the data in the database to disappear?
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Please stand in front of my pistol, smile and wait for the flash - JSOP 2012
|
|
|
|
|
Probably those crazy things he mentioned.
Binding 100,000 items to a list box can be just silly regardless of what pattern you are following. Jeremy Likness
|
|
|
|
|
Richard MacCutchan wrote: crazy things
Yeah probably. I would not be able to guess which one, out of the 4 or 5 billion crazy things that it could be, is causing the problem
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Please stand in front of my pistol, smile and wait for the flash - JSOP 2012
|
|
|
|