|
I am working on a project that i need to print a string and just some database records and i have no idea how to do this on .NET.
Does anyone have just a simple way to do this or an example i can use. I wish it was still like 6.0 that was so easy. Thank you for any help.
PLEASE HELP haaaaaa!!!!
|
|
|
|
|
Add a "PrintDocument" Control to the form...
Private Sub PrintDocument1_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
e.Graphics.DrawString("The String You Want To Print", _
New Font("Arial", 12), _
Brushes.Black, New RectangleF(30, 20, 650, 850))
'30, 20, 650, 850 = these coordinates represent the rectangle in which the give text will be printed
End Sub
Private Sub ToolBar1_ButtonClick(ByVal sender As Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles ToolBar1.ButtonClick
Dim PrintDialog1 As New PrintDialog
PrintDialog1.Document = PrintDocument1
Dim result As DialogResult = PrintDialog1.ShowDialog()
If (result = DialogResult.OK) Then
PrintDocument1.Print()
End If
End Sub
--------------------------
hope this helps you..
Harry
|
|
|
|
|
I have a need to use the ocx controls provided with a software suite to access binary data files. The ocx controls basically amount to get methods which return information stored in the binary file. Works smooth with VB6, but was hoping to use the more robust features of .net.
I have got some methods to work, but methods which return a string fail with a 'type mismatch'. In other words, a method which returns boolean, integer, or double works. Any thoughts on how I could get around this? The ocx is registered, and is currently added by dragging the component onto the form I am working with. Can't get it to work any other way.
Any help is appreciated.
|
|
|
|
|
sbeausol wrote:
The ocx is registered, and is currently added by dragging the component onto the form I am working with. Can't get it to work any other way.
That's the only way to get it to work. You might want to give us some information about where the problem occurs, some code snippets, and maybe a little doc on what the functions of the control are supposed to be returning? You've given us a bunch of 'this works, that works', but nothing on what isn't working.
RageInTheMachine9532
|
|
|
|
|
Some more detailed info:
The ocx filename: xrawfile.ocx
From what I can tell (I don't have the source) it essentially consists of a Class 'XRawfile' which has several get methods. Here is an example of a method which fails in VB .NET type mismatch:
GetCreatorID
long GetCreatorID(BSTR FAR* pbstrCreatorID);
Return Value
1 if successful; otherwise, see Error Codes.
Parameters
pbstrCreatorID A valid pointer to a BSTR. This variable must exist and be initialized to NULL.
Remarks
Returns the creator ID. The creator ID is the logon name of the user when the raw file was acquired.
VB 6 Example
// example for GetCreatorID
BSTR bstrCreatorID = NULL;
long nRet = XRawfileCtrl.GetCreatorID ( &bstrCreatorID );
And here is a method that does work:
GetVersionNumber
long GetVersionNumber(long FAR* pnVersion);
Return Value
1 if successful; otherwise, see Error Codes.
Parameters
pnVersion A valid pointer to a variable of type long. This variable must exist.
Remarks
Returns the file format version number.
VB 6 Example
// example for GetVersionNumber
long nVersionNumber;
long nRet = XRawfileCtrl.GetVersionNumber ( &nVersionNumber );
Again, this method is returning a long (or int in VB .NET)
Thanks for any help
|
|
|
|
|
sbeausol wrote:
long GetCreatorID(BSTR FAR* pbstrCreatorID);
Return Value
1 if successful; otherwise, see Error Codes.
Parameters
pbstrCreatorID A valid pointer to a BSTR. This variable must exist and be initialized to NULL.
Remarks
Returns the creator ID. The creator ID is the logon name of the user when the raw file was acquired.
VB 6 Example
// example for GetCreatorID
BSTR bstrCreatorID = NULL;
long nRet = XRawfileCtrl.GetCreatorID ( &bstrCreatorID );
We still need the code your using in VB.NET so we can see what your doing. How the string your passing is declared, what the function call looks like.
All I can tell you right now is that the string your passing in should be a StringBuilder object.
RageInTheMachine9532
|
|
|
|
|
Here is what I have tried to call it:
Dim Creator as String
XRawfileCtrl.GetCreatorID(Creator)
This results in a type mismatch
Dim Creator as New StringBuilder()
XRawfileCtrl.GetCreatorID(Creator)
This gives me the error:
Value of type 'System.Text.StringBuilder' cannot be converted to 'String'.
Thoughts?
|
|
|
|
|
The more I think about this, the more I think your going to have to modift the MISL code in order to generate the custom marshaler your going to need to get that pointer. It would have been much easier if the library wasn't an ActiveX control.
Basically, since your component is expecting a pointer to a BSTR and expecting to be able to return a pointer to another BSTR, you're going to have to allocate memory for the BSTR and pass the pointer to it to the GetCreatorID function.
The reason for this is because the function your calling will deallocate the BSTR you passed in and will allocate a new one, passing that pointer back to you.
Sorry, but how to do this is out of my realm of experience.
I would need the library your using to be able to play with this and get it to work.
RageInTheMachine9532
|
|
|
|
|
any examples on how I might get started (I don't want to inconvenience you by sending the files)...
What exactly is a BSTR?
Also, would it make sense to use another language - Visual C# or Visual C++... or will I have the same problem...
Thanks for all the help
|
|
|
|
|
sorry didn't login
any examples on how I might get started (I don't want to inconvenience you by sending the files)...
What exactly is a BSTR?
Also, would it make sense to use another language - Visual C# or Visual C++... or will I have the same problem...
Thanks for all the help
|
|
|
|
|
A BSTR is a Unicode array a characters with a 4-byte length on the front of it.
Any of the managed languages would also have to same problem since strings are immutable and the .NET Framework doesn't marshal return pointers to strings back to managed code.
You might want to drop a note to Heath Stewert in the C# forum about marshaling a BSTR to an ActiveX control function and getting a BSTR back. He's really good with the Marshal topics. Be sure to include the code snippets your included here and specify that you are not using P/Invoke to call this method.
RageInTheMachine9532
|
|
|
|
|
How to call an API and implement to travel bertween worksheets using VB 6.0
Anand Chakravarthy
|
|
|
|
|
Hey Anand Chakravarthy
You might want to give a little more specific detail on what you are trying to achieve...
Cliff
|
|
|
|
|
I have just started working with windows programming in VB.NET with Visual Studio .NET 2003. I have created a mainMenu control on a new form object in the visual creator.
When I go to compile the project my menu doesnt show up. Everything else works just fine though, and my compiler doesn't issue any warnings.
I tried the same project in a C# program and it worked just fine. I would just use C# but I have 8 AppDev study CD's in VB.NET.
I also checked that I left all the defaults alone in the properties for the menu.
This is beyond me why this is happening. I would hate to reinstall my VS.NET and hate more to spend hours trying to figure this out.
Can anyone offer solutions?
Nick
|
|
|
|
|
have you included menuitems with your mainMENU?
Marvin N. Guerrero
- Casting More!!
|
|
|
|
|
How do you mean?
When I created the menu in C# - eveything was done automatically.
Also, under the AppDev tutor it was also created automatically. It seems as though VS.NET might be leaving some inportant info behind.
What do you mean by "include menuItems"?
=======================================================================
It takes "me" and two monkeys just to open the box to a light bulb!
|
|
|
|
|
Wow, what do you know... I restarted my computer and all works fine now - I think I need to reinstall my VS.NET 2003
Thanks anyway,
Nick
====================================================================
It takes "me" and two monkeys just to open the box to a light bulb!
|
|
|
|
|
I have developed windows application and it has some crystal report in it, it is working fine on the PC on which i have developed it, but when i install the same application on other PC which has a .Net framework already installed. it shows the error message "keycodev2.dll not found or invalid key code" i have made the setup programm and include all the crystal report files in it but still the error is there. Can you please give me some solusion of these.
Thanks
Kashyap Vakharia
SPR
FIJI ISLAND
|
|
|
|
|
I am creating a component in VB .NET. The component contains a private ArrayList as in the following example:
Private __ItemList As New ArrayList
I need to create a list of the strings contained in this array and expose them in a property drop-down editor in the Properties window when the component is at design-time.
I understand that I can use a custom Type Converter to display a list of strings in a property drop-down, but the values in my SelectedItemConverter class need to come from the main component that exposes the SelectedItemProperty and maintains the __ItemList array list. I am at a loss as to how to get the list of string values into the converter class so it can return the array of strings when the property is accessed.
Here is how far I have gotten:
Private __ItemList As New ArrayList
Dim __SelectedItem As String
|
|
|
|
|
I am having trouble calling the MprAdminConnectionEnum. The call returns a zero error code, but the buffer structure is not complete with data.
Could someone please convert this to a VB.NET Structure.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/rras/rras/ras_connection_0.asp
Information about MprAdminConnectionEnum is at:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/rras/rras/mpradminconnectionenum.asp
I would be overly greatful for a working example!
Thankyou to anyone!
MASOSi
|
|
|
|
|
plzz;
I have problem ?
how can send oledbdatareader from function like :
public function sss() as oledbdatareader
...
dim z as oledbdatareaedr=...
return z
end function
and how can i use it in other methods like:
dim x as oledbdatareader=sss()
.......
is this algorithm rigth , or no ?
and if it is wrong plzzz write small code to tech me .
thnks for allllllllll
Think Before Begin
|
|
|
|
|
Your brief example, which I assume omits the implementation details, looks essentially correct.
What a piece of work is man, how noble in reason, how infinite in faculties, in form and moving how express and admirable . . . and yet to me, what is this quintessence of dust? -- Hamlet, Act II, Scene ii.
|
|
|
|
|
as topic, i wan to disable to user from resize the form size.. anyway can do this? anyhelp is appreciated... VB.NET
|
|
|
|
|
1. Change the FormBorderStyle Property of the form to FixedSingle or FixedDialog
2. Override the OnResize method and set the size to be constant.
Free your mind...
|
|
|
|
|
In VB.Net form, under Properties of the form, you should set the Maximize button to "FALSE" and there is a Minimumzise & Maximumsize that you need to supply its values in order to disable the maximize button, e.g form size is 300X300, so set Minimumsize to 300 & maximumsize to 300...
|
|
|
|