|
Hey - that's another excuse for me to start using it. Thanks Dave.
...Steve
|
|
|
|
|
I would like to know abt the code for Printing on a Predesigned Bill and the data for the respective fields will be retrieved from Oracle
Pls mail me how to code for Printing on the Bill layout ie image fill in VB6.0
Regards
Anup Singh J.
** A Fighter Never Loses !!!!
|
|
|
|
|
I don't think there is a print preview control in VB6.0
Perhaps you should look at Crystal Reports?
'--8<------------------------
Ex Datis:
Duncan Jones
Merrion Computing Ltd
|
|
|
|
|
Is there any example in VB.Net which shows how to create a class dynamicaly at runtime?
|
|
|
|
|
As it happens I've just done some work where I was doing this kind of thing and I also did some further experiementation after completing the project. this example is in C# but you should be able to convert it to VB easily enough
using System.Reflection;
string continentFactory = "PatternsTest.AfricaFactory";
object target = null;
Binder binder = null;
string methodName = null;
object[] args = null;
Type continentType = assembly.GetType(continentFactory);
target = null;
methodName = null;
args = null;
ContinentFactory continentInstance = (ContinentFactory) continentType.InvokeMember(
methodName,
BindingFlags.DeclaredOnly |
BindingFlags.Public |
BindingFlags.Instance |
BindingFlags.CreateInstance,
binder,
target,
args
);
Kevin
|
|
|
|
|
Hi all...
Since I upgraded to .Net from VB 6, when creating public classes with public events I use:
<br />
Public Event MyEvent(ByVal ParameterName as Type)<br />
In one project this didn't work, the event sometimes does not raise, I searched the MSDN and I found:
Note: Non-shared events should not be raised within the constructor of the class in which they are declared. Although such events do not cause runtime errors, they may fail to be caught by associated event handlers. Use the Shared keyword to create a shared event if you need to raise an event from a constructor.
I changed the statement to be like:
<br />
Public Shared Event MyEvent(ByVal ParameterName as Type)<br />
It worked fine.
I'm not familiar with what Shared does, but should I use it with every Public Event declaration?
|
|
|
|
|
The Shared declaration makes a variable, event or method static. In other words, you do not need to create a class instance to access a Shared member.
Shared allows you to trap an event raised in a class constructor because the class instance itself is not yet fully initialized, but you do not need an instance because the event is static.
But it is not a good idea to use Shared in most cases, because typically you want events and property vcalues to be associated with a specific instance. When you raise a shared event, the application has no way of knowing which, if any, instance the event was raised from. Similarly, when you set the value of a shared property, the value will be set in any and all instances of the class.
See the MSDN, it describes the behavior of Shared members in detail.
|
|
|
|
|
rwestgraham wrote:
But it is not a good idea to use Shared in most cases, because typically you want events and property vcalues to be associated with a specific instance. When you raise a shared event, the application has no way of knowing which, if any, instance the event was raised from. Similarly, when you set the value of a shared property, the value will be set in any and all instances of the class.
Thank you rwestgraham for your reply...
My problem is i'm not rasing the event from within the constructor, i noticed that the event raised one of two times i click the button that raise the event, i posted the code below maybe this will help to understand the problem, the code is not completed 'cause i stopped once i noticed this problem:
The event that does not raise is the DataArrival event
Private Class UserConnection
Private __TcpClient As TcpClient
Private __ConnectionID As Integer
Private __ReadBufferSize As Integer
Private __ReadBuffer As Byte()
Public Event DataArrival(ByVal ConnectionID As Integer, ByVal rDataByte As Byte(), ByVal rDataStr As String)
Public Event ConnectionLost()
Public Event ConnectionClosedByClient()
Public Sub New(ByVal ClientConnection As TcpClient, Optional ByVal ReadBufferSize As Integer = 255)
__TcpClient = ClientConnection
__ReadBufferSize = ReadBufferSize
ReDim __ReadBuffer(__ReadBufferSize)
Me.__TcpClient.GetStream.BeginRead(__ReadBuffer, 0, __ReadBufferSize, AddressOf StartRead, Nothing)
End Sub
Private Sub StartRead(ByVal AR As IAsyncResult)
Dim BytesRead As Integer
Dim strMessage As String
Try
SyncLock __TcpClient.GetStream
BytesRead = __TcpClient.GetStream.EndRead(AR)
End SyncLock
strMessage = Encoding.ASCII.GetString(__ReadBuffer, 0, BytesRead)
RaiseEvent DataArrival(__ConnectionID, __ReadBuffer, strMessage)
SyncLock __TcpClient.GetStream
ReDim __ReadBuffer(__ReadBufferSize)
__TcpClient.GetStream.BeginRead(__ReadBuffer, 0, __ReadBufferSize, AddressOf StartRead, Nothing)
End SyncLock
Catch e As SocketException
MessageBox.Show(e.ToString, e.NativeErrorCode.ToString)
End Try
End Sub
Public Sub SendData(ByVal Data As String)
SyncLock __TcpClient.GetStream
Dim writer As New IO.StreamWriter(__TcpClient.GetStream)
writer.Write(Data)
writer.Flush()
End SyncLock
End Sub
Public Sub SendData(ByVal Data As Byte())
SyncLock __TcpClient.GetStream
Dim writer As New IO.StreamWriter(__TcpClient.GetStream)
writer.Write(Data)
writer.Flush()
End SyncLock
End Sub
Public Property ConnectionId() As Integer
Get
Return __ConnectionID
End Get
Set(ByVal Value As Integer)
__ConnectionID = Value
End Set
End Property
End Class
|
|
|
|
|
The DataArrival event is only raised from the StartRead function. StartRead is not called by any of the other class member functions, and it is declared Private so you cannot call it externally. I would guess that the event is never raised because StartRead is never executed. ???
|
|
|
|
|
Okay .... this is a really stupid question...
Some time ago I made a WEBservice for a company on my server. The webservice takes an XMLdokument and does some magic. Several other servers is involved. To bad they are really really slow ...
My client creates the dokument and send it to WEBservice and then clients app is just waiting ... wainting and waiting until it gets a WEBService timeout. Sooo ... Can I set timeout-value somewhere or do I have to think it all over again? Maybe client shall send me smaller XMLS:s and call WEBservice more frequent to avoind the timeout?
Fast responses please ....
Regards // Maw
|
|
|
|
|
How to grab a form's content into another form? I was to show a form in another form.
|
|
|
|
|
The form which you want to show in another form must have "SetTopLevel(False)", then you can add this form like any other control.
public Class InnerForm<br />
inherits System.Windows.Forms.Form<br />
<br />
Public Sub New()<br />
MyBase.New()<br />
InitializeComponent()<br />
<br />
Me.SetTopLevel(False)<br />
End Sub<br />
End Class<br />
<br />
public Class OuterForm<br />
inherits System.Windows.Forms.Form<br />
<br />
Public Sub AddInner(innerf as InnerForm)<br />
me.controls.add(innerf)<br />
innerf.show()<br />
End Sub<br />
End Class
hope this will help you
|
|
|
|
|
Hello
I'd like to visualize some data in a datagrid. The data is structured into two different classes.
After the startup of the form I'd like to display only the data of the first class and then I'd like to display a plus-minus symbol in the row header where the user can click and disply the data of the subclass. Here a small example. Main Class: Drinks and Food, Subclasses for Drinks: Beer, Coke, Sprite and for Food: Hamburger, French Fries.
How can I only display the two rows Drinks and Food at startup and then when the user clicks on the plus-minus symbol in the row header of Drinks the program will also display sub categories Beer, Coke and Sprite directly under the row Drinks?
To me it seems to be something like a TreeView but I should be able to insert multiple columns and I'd like to display the same colums in the main class as in the sub classes.
I tried it with data relations but this will only generate a separate table for the sub classes and will not display it in the same datagrid together with the main class.
Does anybody know an answer?
Thanks in advance
Dave
|
|
|
|
|
I have a windows forms application where I need to download or get access to a response stream for a requested URL (In my case a gif file). The website uses forms authentication and therefore requires an authentication cookie and no resources on the site can be downloaded without first being redirected to a login page. I found this article Screen Scraping, ViewState, and Authentication using ASP.Net[^] from which I converted C# to VB.NET (the main difference is that the example code is run from an asp.NET application). However when I try to run my code I get a WebException (500) Internal Server Error.
Here is my code, does anyone have any suggestions or hints/another way of doing this?
<br />
Dim strPageURL As String = "http://localhost/MySite/images/uk.gif"<br />
Dim strLoginURL As String = "http://localhost/MySite/login/login.aspx"<br />
<br />
'first, request the login form to get the viewstate value<br />
Dim webReq As HttpWebRequest = DirectCast(WebRequest.Create(strLoginURL), HttpWebRequest)<br />
webReq.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)"<br />
<br />
webReq.Credentials = New NetworkCredential(Me.ContainerForm.UserName, Me.ContainerForm.Password)<br />
<br />
Dim stmResponseReader As New StreamReader(webReq.GetResponse.GetResponseStream)<br />
Dim strResponseData As String = stmResponseReader.ReadToEnd<br />
stmResponseReader.Close()<br />
<br />
'extract the viewstate value and build out POST data<br />
Dim strViewState As String = ExtractViewState(strResponseData)<br />
Dim postData As String = [String].Format("__VIEWSTATE={0}&txtUsername={1}&txtPassword={2}&btnLogin=Login", strViewState, Me.ContainerForm.UserName, Me.ContainerForm.Password)<br />
<br />
'have a cookie container ready to receive the forms auth cookie<br />
Dim cookies As New CookieContainer<br />
<br />
'now post to the login form<br />
webReq = DirectCast(WebRequest.Create(strLoginURL), HttpWebRequest)<br />
webReq.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)"<br />
webReq.Credentials = New NetworkCredential(Me.ContainerForm.UserName, Me.ContainerForm.Password)<br />
webReq.Method = "POST"<br />
webReq.ContentType = "application/x-www-form-urlencoded"<br />
webReq.CookieContainer = cookies<br />
<br />
'write the form values into the request message<br />
Dim requestWriter As New StreamWriter(webReq.GetRequestStream())<br />
requestWriter.Write(postData)<br />
requestWriter.Close()<br />
<br />
'we don't need the contents of the response, just the cookie it issues<br />
webReq.GetResponse().Close()<br />
<br />
'now we can send out cookie along with a request for the protected page<br />
webReq = DirectCast(WebRequest.Create(strPageURL), HttpWebRequest)<br />
webReq.Credentials = New NetworkCredential(Me.ContainerForm.UserName, Me.ContainerForm.Password)<br />
webReq.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)"<br />
webReq.CookieContainer = cookies<br />
<br />
'ERROR OCCURS HERE<br />
Dim stmResponse As Stream = webReq.GetResponse().GetResponseStream()<br />
<br />
Me.PictureBox1.Image = Image.FromStream(stmResponse)<br />
Jim
|
|
|
|
|
I plan to develop a com+ serviced component in Windows 2000 server. Now my requirement is that the deployed serviced component should be available to client applications developed as a Windows Applications (Winforms) and running on Client machines in the network.
ie. How should i access the serviced component in a Windows Application (winforms) ???
I plan to deploy some serviced components, which i want to access from ASP.net applications and also through Windows applications ???
Could anyone help ???
Chandru
|
|
|
|
|
Export the service component installation setup and embed it in desktop setup application. when you application will run it will prompt the user with the server name to provide which you will save in the registry or any ini file. then in the code u have to use
object=createObject("project.class",ServerName)
and it will create the object for that server.
test and let me know if any thing goes wrong.
|
|
|
|
|
could u just brief a little abt the export & embed steps u mentioned in the reply. I'm not clear abt it.
|
|
|
|
|
well do the following
go to control Panel-administrative tools then Component Services.
in Component services create a new Package and add the components in it. Do it this way dont do it through dot net command prompt. now right click on the package and export it. User Server Option in the export with name Suppose "abc.msi". now this abc is the setup of components for you. Go to your VB.Net project. You had already added the deployment project. in this project add this Exe and put the custom event to run the setup during main setup. Now when you will install the package at client.(Assuming Server is already installed on machine X) now on the startup form suppose logon fomr you will check first on load that there is any entry for the server in any text file. if no then prompt the user to enter the server Name and he will enter the name "X" now you will test the connection by creating object as I told you in my previous reply. if the connection goes fine then you are done and if not then let me know again
Best of luck
|
|
|
|
|
thank you for advice. i'm new to serviced components programming. just learning the tricks. Hop u will help me. I understood what u told. But i could not make it into practise.
1. I just created a serviced component class with a public method which returns a string. And registered in the component services. Now according
to the .net principle now if i create a client project and on the form if i add the line "imports SERVERCOMPONENT" the component will be accessible in the form. Is'nt it ... or do i need to add the component by going to the add reference and linking the component ???
I will add the code for your reference ...
ServerLibrary.cs
Imports System.EnterpriseServices
Imports System.Runtime.CompilerServices
Imports System.Reflection
<assembly: applicationname("serverclass")="">
<assembly: assemblykeyfileattribute("d:\netprj\servicedcomponent\serverlibrary\serverclass.snk")="">
Namespace Serverclass
<transaction(transactionoption.required)> _
Public Class ServerClass
Inherits ServicedComponent
<autocomplete()> _
Public Function DoSomething() As String
Return " From a Serviced Component"
End Function
End Class
End Namespace
This class i compile and i'm adding it in the com+ servcies. The component is available in the component services.
And on the same machine i'm adding a client vb.net project .. i'm adding
imports serverclass
or imports serverlibrary.serverclass on the form code
Now the class is not available for instantiation .....
2. As u said in the previous reply after getting the above client ready I have to add a deployment project and then add the component export file to make the client installation file. Is'nt it ...
Chandru
|
|
|
|
|
ok lets get this way.
1. you created a class project which you will deploy on transaction server.
2. In transaction server you will right click on the newly created package (as mentioned in last reply..how to create package)by you and click export. it will create a setup file which will be deployed at the client side which you will embbed in the client setup project.
3. or do not embbed it . run the client setup one one machine and also run this exported setup on that machine one by one.
4, in code of client project you WILL NOT ADD ANY REFERENCE of this project. what you will do is the
Dim obj as object
obj=CreateObject("ProjectName.ClassName",ServerName)
' where servername is the name of the server where transaction server is
this will create an object and after that you will call the fuynction inside obj like
obj.FunctionName(parameters)
best of luck
and let me know if any problem comes
|
|
|
|
|
Now I have created the client application in which i call the following code
in the button click event ...
But an error occurs ...
Microsoft.VisualBasic cannot create ActiveX component. Now why is this happening ????
ServerClass is the serviced component class
chandru is the server name
dosomething is a public method in the component which returns a string.
now i'm testing the client project on the same server machine.i thoght after testing the client on the same server machine, i could then test it on the different machine ..
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim AA As Object
Try
AA = CreateObject("ServerClass", "chandru")
MsgBox(AA.dosomething())
Catch ee As Exception
MsgBox(ee.Source & ee.Message)
End Try
End Sub
Server Component code ....
Imports System.EnterpriseServices
Imports System.Runtime.CompilerServices
Imports System.Reflection
<assembly: applicationname("serverclass")="">
<assembly: assemblykeyfileattribute("d:\netprj\servicedcomponent\serverlibrary\serverclass.snk")="">
Namespace Serverclass
<transaction(transactionoption.required)> _
Public Class ServerClass
Inherits ServicedComponent
<autocomplete()> _
Public Function DoSomething() As String
Return " From a Serviced Component"
End Function
End Class
End Namespace
|
|
|
|
|
AA = CreateObject("ServerClass", "chandru")
this line has problem... it should be like this
AA = CreateObject("ProjectName.ServerClass", "chandru")
and it will start working for you secondly I did not used namespace in my project as I dont know how to create object for that
i did this way
' I did not put require transaction here as I need to commit transaction per
' function instead of per object creation. its all on the requirement
Public Class DC
Inherits EnterpriseServices.ServicedComponent
my email is wet51@hotmail.com (you can add me on messenger if required)
|
|
|
|
|
It works now. That was very nice of you to have me guided like this. Thanks a lot.
I plan put some serviced components on Windows 2000 server. Now some of my client machines on the network has windows 98 os. Will i be able to install the exported serviced component (.msi file) on the client machine ..
Or is there any other mechanism through which i can access the serviced components from a Windows 98 client machine .. ????
chandru
|
|
|
|
|
good news your problem is solved. for 98 I have never run the program. over there, there is no transaction server but there is DCOM which I guess should work. run the MSI on the client 98. if it does not then from Transaction server export the package again but this time choose the client option instead of server.
there is one other way of registering the components on clinet 98. but I have never used that so on 98 you have to explore that.
click start then run and write there
DCOMcnfg
press enter and you will see the window where components are registered.you can manually do this once and then write the script file for 98 windows. so best of luck for 98 as in this windows i am unable to help you more then this.
|
|
|
|
|
if u feel its ok .. pls give me your mail id maybe i could get in touch with u.
|
|
|
|