|
I need to interface with a dll from VB.NET. I have example code of calling a function in that DLL in VBA it is as follows:
Private Declare Function BuildKeyboardList Lib "keyman32" (ByRef pKbdInfo As Any, ByRef pCount As Long) As Long<br />
Private Sub MySub()<br />
Dim xxx As Long = 0<br />
If BuildKeyboardList(ByVal xxx, nLayouts) = 0 Then Exit Sub<br />
...<br />
ReDim KeybdInfo(nLayouts)<br />
If BuildKeyboardList(KeybdInfo(1), nLayouts) = 0 Then Exit Sub<br />
...<br />
End Sub
How do I Declare This Function in VB.NET with an "Any" argument, that sometimes will be a long and other times will be a structure?
How do I Call this function sometimes ByVal and other times ByRef in VB.NET?
Rand
|
|
|
|
|
I don't pretend to know the details of the marshal syntax, but I've found examples for the SendMessage API (which has the last parameter as any in VB6):
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, _
<MarshalAs(UnmanagedType.AsAny)> ByVal lParam As Object) As Integer
Not sure of the ramifications of designating a parameter as unmanaged type but this seems to work in the above example, perhaps you can try it with your API call.
-- modified at 19:30 Monday 31st October, 2005
|
|
|
|
|
I am trying to find a control or a tool that I can use with VB.NET so that the data I retreive from a data base can be displayed on the screen in a form like Excel. For example, suppose I have a form on the screen, like a grid table, with 20 raws and I fill only 15 raws with data. The other 5 raws are empty. In other words, I need a way to display a 20 raws grid table with some of these raws filled with data. Editing of these data is, of course, needed.
Any advice on that ?
|
|
|
|
|
I am trying to upload files to a remote server. If i use Webclient.uploadfile(....) with the <method> POST then i get an error (405) method not allowed. Alternatively, if i use <method> PUT the files are upload well but the program modifies the contents of my files (by adding text into file) hence corrupting my files.
Any ideas or other solutions of getting this done will be highly appreciated.
Qariuki
|
|
|
|
|
I need a to connect to an accesspoint and get the MAC adress using SSH.
Anybody who has done something like this?
|
|
|
|
|
In the following code I need to assign the value for the epfNo(bolded) as variable ... How to make it in a sql query..?
With Adodc1
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
App.Path & "\ot.mdb;Persist Security Info=False"
sqlStr = "select * from OTJob WHERE epfNo='0122'"
.RecordSource = sqlStr
End With
Jena..
|
|
|
|
|
jenagan wrote: With Adodc1
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
App.Path & "\ot.mdbersist Security Info=False"
sqlStr = "select * from OTJob WHERE epfNo='0122'"
.RecordSource = sqlStr
End With
With Adodc1
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
App.Path & "\ot.mdbersist Security Info=False"
sqlStr = "select * from OTJob WHERE epfNo='0122'"
.RecordSource = sqlStr
End With
use this :
Dim strEpfNo = "0122"<br />
sqlStr = "select * from OTJob WHERE epfNo='" & strEpfNo & "'"
R A M
|
|
|
|
|
In Microsoft Access 2000, it is easy to print a WYSIWYG form that looks exactly as it does on the screen. Looking through various threads, I didn't find anything -- maybe didn't search long enough. In VBA on Access, it's easy. How is it done in VB.net?
Rich Locus
|
|
|
|
|
I should have included a code sample from Access.
The function, which I call from a Form Event, prints an exact copy of the form.
This is all it takes in VBA on Access:
Function PrintWYSIWYGForm()
On Error GoTo macPrintForm_Err
DoCmd.PrintOut acPrintAll, , , acHigh, 1, True
macPrintForm_Exit:
Exit Function
macPrintForm_Err:
MsgBox Error$
Resume macPrintForm_Exit
End Function
Sure would be nice if something existed like that in Visual Basic.net.
Rich Locus
|
|
|
|
|
There's a Windows Forms control called 'PrintDocument'. Add one to your form. It has a Print method. It actually will print out a blank page, I just discovered. However, I'm sure this is where your solution lies, perhaps google can fill the blanks ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I am trying to create a VB.NET smooth progress bar custom control that also displays the percent in the middle. To prevent flicker I calculate the part of the control rectangle that has changed when the progress value is updated. To force the text in the middle to also be updated I also calculate a second rectangle that bounds the text. Then I call Invalidate method using the Union method with the two rectangles - the progress bar rectangle and the text rectangle.
This works fine and does not flicker until the progress rectangle reaches the text rectangle. Once it reaches the text rectangle, and at all points even after it passes the text rectangle, there is flicker.
Any suggestions??
|
|
|
|
|
You can turn on double buffering for your application.
this.SetStyle( ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer | ControlStyles.UserPaint | ControlStyles.ResizeRedraw, true );
That's the C# version
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thanks, that helps. I still don't understand why a region that is not invalidated would flicker, but ....
|
|
|
|
|
I have to read from a text file, but I can't get all of the fields out. As you can probably see, there is no real delimiter. Someone please help me.
1 ANSARI, EHSAN B 111-11-111 BT SR CSCI P Enrolled
2 CRAWFORD, BRIAN KEITH 111-11-111 BT SR CSCI P Enrolled
3 ELLIS, RICHARD M 111-11-111 BT SR CSCI P Enrolled
4 GARDNER, JAMES ROBY 111-11-111 BT SR CSCI P Enrolled
5 GNAU, DANIEL C 111-11-111 BT SR CSCI A Enrolled
7 GOULDER, JEFFREY SCOTT 111-11-111 BT SR CSCI P Enrolled
8 LAWSON, BRANDI NICOLE 111-11-111 BT SR CSCI P Enrolled
9 MONROE, JENNIFER M 111-11-111 BT SR CSCI P Enrolled
10 MOORE, MELISSA ANN 111-11-111 BT SR CSCI P Enrolled
11 OVERHOLT, JAMES PATRIC 111-11-111 BT SR CSCI P Enrolled
12 PARKER, BRIAN DOUGLAS 111-11-111 BT SR CSCI P Enrolled
I've got some code and it loops through all rows, but how can I get all of the "columns" extracted?
Here's my code:
Public Sub LoadStudents(ByVal strFile As String)
Dim fs As New FileStream(strFile, FileMode.Open)
Dim sr As StreamReader
Try
sr = New StreamReader(fs)
Dim str As String
Dim ar As String()
Do While sr.Peek <> -1
str = sr.ReadLine
If str.Trim.Length <> 0 Then
ar = str.Split(CChar(" "))
stud = New Student
With stud
.Number = CType(ar(0), Integer)
'.Last = CType(ar(1), String).Substring(0, .Last.Length - 1)
'Fix above parsing error
.Last = CType(ar(1), String)
.First = CType(ar(2), String)
.MidI = CType(ar(3), String)
.ID = CType(ar(4), String)
.College = CType(ar(5), String)
.Classification = CType(ar(6), String)
.Email = CType(ar(7), String)
.Major = CType(ar(8), String)
.Paid = CType(ar(9), String)
.Enrolled = CType(ar(10), String)
End With
End If
Loop
Catch ex As Exception
Exception(ex)
Finally
fs.Close()
sr.Close()
End Try
End Sub
|
|
|
|
|
Sorry for the error in my description due to copying and pasting the contents of the text file.
Some spacing are as follows:
1. Glavin, Tom 111-11-1111 BT SR CSCI P Enrolled
2. Justice, David 111-11-1111 BT SR CSCI P Enrolled
|
|
|
|
|
Looking at the data it seems that a space character separates the various columns of data. The exception though is that the first name can contain more than one name (i.e. the student's middle names as well). That's the trick to parsing this data.
The code you have should work with the addition of detecting the number of first and middle names. To that end I'd inspect the value of UBound(ar). For a person with no middle name the UBound should be = 9, with one middle name = 10, with two middle names = 11 and so on.
You could use this information to set a variable as the index to the ar() string array and automatically capture the data columns viz:
With stud
.Number = CType(ar(0), Integer)
'.Last = CType(ar(1), String).Substring(0, .Last.Length - 1)
'Fix above parsing error
.Last = CType(ar(1), String)
.First = CType(ar(2), String)
' Determine the index of the middle name if it exists.
' This logic will need to be changed slightly if multiple
' middle names are expected in the data.
Dim n As Integer
n = UBound(ar) - 9
If n = 0 Then
.MidI = vbNullString ' or "" depending on your requirments
Else
.MidI = CType(ar(3), String)
End If
.ID = CType(ar(n + 3), String)
.College = CType(ar(n + 4), String)
.Classification = CType(ar(n + 5), String)
.Email = CType(ar(n + 6), String)
.Major = CType(ar(n + 7), String)
.Paid = CType(ar(n + 8), String)
.Enrolled = CType(ar(n + 9), String)
End With
There are several assumptions in the above code, but you should get the idea how it works.
...Steve
|
|
|
|
|
There are only last, first, and middle initial. The even spacing was a typo. I pasted directly from the text file but the spacing didn't stay for some reason. Please look at my reply to the post using the actual spacing issues I encountered.
Thanks for your reply!
|
|
|
|
|
My code will still work since it does not matter how many spaces tere are between the data columns and also the middle initial/name does not exists for some entries but does for others.
...Steve
|
|
|
|
|
hi.
advanced programmer, but new to vb.net.
can anyone recommend a control or know which one microsoft word uses for it's document window?
same one as in vb.net's code editor window.
eg. you type incorrect spelling in this control and it underlines errors, colors your text, adds spaces for your code, etc.
like some really advanced textbox control, what is it?
cheers all and look forward to all your suggestions
--Graham
|
|
|
|
|
HeroRaven wrote: can anyone recommend a control or know which one microsoft word uses for it's document window?
Word uses its own proprietary control for its "text editor"
My: Blog | Photos
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucious
|
|
|
|
|
You could try the one that comes with QueryCommander. It looks very similar to the VS.NET IDE. Might do something that Word can, but I have not messed with it much. http://sourceforge.net/projects/querycommander
The network is down...let's go get bagels.
|
|
|
|
|
do you really believe MS Word were programmed with VB.NET ?????
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
it's not one control. you can try to implement all the things by yourself. for example, for spell check, there is aspell, etc...
|
|
|
|
|
yeah i know that but for changing text in the textbox in realtime, putting color underlines, etc.
and yeah microsoft announced a few years back ms word was programmed in vb. so i'm pretty sure the new versions were too.
|
|
|
|
|
I have a program that handles my DVD collection. It is a VB.net front-end with an Access dB. I am trying to load a picture (dvd covers) into the dB. I want to be able to save a bitmap or jpeg for each record. I have the load option down but my program won't save into the database. I click the save button and nothing happens. The save option has worked fine until I added this section of code.
In the dB, the picture column is a OLE Object and when I did my dB connection in VB.net, the schema showed that the picture column was a base64binary. After running some test, it seems one line of code is causing this problem but I don't know what to put there. It is in the data binding code where I have "picDVD.DataBindings.Add("long", dsDVD, "DVD.Cover Pic")". The quotations around long is what I don't know what to use. I am uncertain of what datatype of for base64binary.
Does any of this make sense? If so, any advice would be greatly appreciated! Thank you.
Jason
I'd rather have a bottle in front of me than a frontal lobotomy.
|
|
|
|