|
how can i simulate right button click in a VB6 program
plzzzzzzzzzzzzzzzzzzzz help
and plz do tell how can i simulate left button click with its single click and double click properties in VB6
FARAH
|
|
|
|
|
Are you trying to send this mouse click to your own code?? Or to an outside application??
In your own code, you do'nt have to simulate a mouse click. How you reorganize your code to allow calling it from other places depends on what your code is doing in its mouse click event.
If an outside app, look into getting the window handle of the control you want to send the mouse click to and use the Win32 API function SendMessage to send a properly formatted mouse window message to the target window.
|
|
|
|
|
Private Sub Button1_Click(... )
dim f as new form1
f.MdiParent = Me
f.show()
ens sub
this code allways creates a new mdi child i need only one instance at a time. how can i prevent duplicating form1 ?
i am using vs2003
thanks
|
|
|
|
|
Hi,
In the main form:
Private Sub Button1_Click(... )
if bLoaded = True then Exit Sub
dim f as new form1
f.MdiParent = Me
bLoaded = True
f.show()
ens sub
'... in form1.Closed
bLoaded = False
.... in a module
Friend bLoaded as Boolean = False
hope this helps
|
|
|
|
|
thanks 4 ur reply!
is there any other way to load a form other than
"dim f as new form1" this way ?
|
|
|
|
|
Hi,
You could simply execute Form.Show() [VB2005], but form1 is a class and I prefer to create an instance of it explicitly using the New Keywork
regards
|
|
|
|
|
there is no Show() member function found for form1. is it bcause of vb2003?
|
|
|
|
|
No, there isn't. The advice was bad. There is another way of creating an instance of a form, but involves Reflection and a lot more code than just myForm = New MyFormClass .
|
|
|
|
|
If you want to use the control that is used in the windows Task Manager to show the task and status for an application then follow these steps:
1.) Add a ListView to your form
2.) Set the "View" property to "Details"
3.) Go to the "Columns" property and click in the text field next to the word "Columns" where it says "(Collection)" and then click on the small button marked "..."
4.) Add a ColumnHeader by clicking the "Add" button
5.) Name your ColumnHeader
6.) Type the title that you want on the ColumnHeader in the text field next to the word "Text" and your done
OPTIONAL
LabelEdit Property - If this property is set to true the user can double-click an item in the listview to be able to change it.
|
|
|
|
|
Is there a question in here, or just a piece of advice ?
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
when i am running my application created from vb.net the following error is display
" System.IO.FileNotFoundException: Could not load file or assembly 'ADODB, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
File name: 'ADODB, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' "
i am using adod control
setup also installed in that machine , the os in the machine is windows xp home edition service pack 2
solution pls
sathish
-- modified at 23:57 Friday 20th July, 2007
|
|
|
|
|
Googling for "Could not load file or assembly 'ADODB" gives lots of hits, starting
with this one.[^]
I would suggest you read it; seems you are not the first with that problem.
|
|
|
|
|
I am working in VB.net 2003.
The project is to convert some fortran code to vb.
I have a set of fortran routines and one function.
I have converted them to the best of my abilty but have a few remaining problems: (at least I hope so)
Problem 1^^^^^^^^^^^^^^^^^^
"Value of type 'Double' cannot be converted to '2-dimensional array of Double"
This is the line raising the error: eight lines after the "180:"
Call DBNFAC(W(IWP, 1), NWROW, N, ILB, IUB, IFLAG)
Problem 2^^^^^^^^^^^^^^^^^^
What should be done with the Dim statements from fortran.
they are commented out just above the line:
'***FIRST EXECUTABLE STATEMENT DBINT4
Here is the code. Any clues would be most appriciated.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Sub DBINT4(ByVal X() As Double, ByVal Y() As Double, ByVal NDATA As Integer, ByVal IBCL As Integer, ByVal IBCR As Integer, ByVal FBCL As Double, ByVal FBCR As Double, ByVal KNTOPT As Integer, ByVal T() As Double, ByVal BCOEF() As Double, ByVal N As Integer, ByVal K As Integer, ByVal W(,) As Double)
'***BEGIN PROLOGUE DBINT4
'***DATE WRITTEN 800901 (YYMMDD)
'***REVISION DATE 820801 (YYMMDD)
'***CATEGORY NO. E1A
'***KEYWORDS B-SPLINE,DATA FITTING,DOUBLE PRECISION,INTERPOLATION,
' SPLINE
'***AUTHOR AMOS, D. E., (SNLA)
'***PURPOSE Computes the B-representation of a cubic spline
' which interpolates data (X(I),Y(I)),I=1,NDATA.
'***DESCRIPTION
'
' Written by D. E. Amos, August, 1979.
'
' References
' SAND-78-1968
'
' A Practical Guide to Splines by C. de Boor, Applied
' Mathematics Series 27, Springer, 1979.
'
' SIAM J. Numerical Analysis, 14, No. 3, June, 1977, pp.441-472.
'
' Abstract **** a double precision routine ****
'
' DBINT4 computes the B representation (T,BCOEF,N,K) of a
' cubic spline (K=4) which interpolates data (X(I),Y(I)),
' I=1,NDATA. Parameters IBCL, IBCR, FBCL, FBCR allow the
' specification of the spline first or second derivative at
' both X(1) and X(NDATA). When this data is not specified
' by the problem, it is common practice to use a natural
' spline by setting second derivatives at X(1) and X(NDATA)
' to zero (IBCL=IBCR=2,FBCL=FBCR=0.0). The spline is defined
' on T(4) .LE. X .LE. T(N+1) with (ordered) interior knots at
' X(I) values where N=NDATA+2. The knots T(1),T(2),T(3) lie to
' the left of T(4)=X(1) and the knots T(N+2), T(N+3), T(N+4)
' lie to the right of T(N+1)=X(NDATA) in increasing order. If
' no extrapolation outside (X(1),X(NDATA)) is anticipated, the
' knots T(1)=T(2)=T(3)=T(4)=X(1) and T(N+2)=T(N+3)=T(N+4)=
' T(N+1)=X(NDATA) can be specified by KNTOPT=1. KNTOPT=2
' selects a knot placement for T(1), T(2), T(3) to make the
' first 7 knots symmetric about T(4)=X(1) and similarly for
' T(N+2), T(N+3), T(N+4) about T(N+1)=X(NDATA). KNTOPT=3
' allows the user to make his own selection, in increasing
' order, for T(1), T(2), T(3) to the left of X(1) and T(N+2),
' T(N+3), T(N+4) to the right of X(NDATA) in the work array
' W(1) through W(6). In any case, the interpolation on
' T(4) .LE. X .LE. T(N+1) by using function DBVALU is unique
' for given boundary conditions.
'
' DBINT4 calls DBSPVD, DBNFAC, DBNSLV, D1MACH, XERROR
'
' Description of Arguments
'
' Input X,Y,FBCL,FBCR,W are double precision
' X - X vector of abscissae of length NDATA, distinct
' and in increasing order
' Y - Y vector of ordinates of length NDATA
' NDATA - number of data points, NDATA .GE. 2
' IBCL - selection parameter for left boundary condition
' IBCL = 1 constrain the first derivative at
' X(1) to FBCL
' = 2 constrain the second derivative at
' X(1) to FBCL
' IBCR - selection parameter for right boundary condition
' IBCR = 1 constrain first derivative at
' X(NDATA) to FBCR
' IBCR = 2 constrain second derivative at
' X(NDATA) to FBCR
' FBCL - left boundary values governed by IBCL
' FBCR - right boundary values governed by IBCR
' KNTOPT - knot selection parameter
' KNTOPT = 1 sets knot multiplicity at T(4) and
' T(N+1) to 4
' = 2 sets a symmetric placement of knots
' about T(4) and T(N+1)
' = 3 sets T(I)=W(I) and T(N+1+I)=W(3+I),I=1,3
' where W(I),I=1,6 is supplied by the user
' W - work array of dimension at least 5*(NDATA+2)
' If KNTOPT=3, then W(1),W(2),W(3) are knot values to
' the left of X(1) and W(4),W(5),W(6) are knot
' values to the right of X(NDATA) in increasing
' order to be supplied by the user
'
' Output T,BCOEF are double precision
' T - knot array of length N+4
' BCOEF - B spline coefficient array of length N
' N - number of coefficients, N=NDATA+2
' K - order of spline, K=4
'
' Error Conditions
' Improper input is a fatal error
' Singular system of equations is a fatal error
'***REFERENCES D.E. AMOS, *COMPUTATION WITH SPLINES AND B-SPLINES*,
' SAND78-1968, SANDIA LABORATORIES, MARCH 1979.
' C. DE BOOR, *PACKAGE FOR CALCULATING WITH B-SPLINES*,
' SIAM JOURNAL ON NUMERICAL ANALYSIS, VOLUME 14, NO. 3,
' JUNE 1977, PP. 441-472.
' C. DE BOOR, *A PRACTICAL GUIDE TO SPLINES*, APPLIED
' MATHEMATICS SERIES 27, SPRINGER, 1979.
'***ROUTINES CALLED D1MACH,DBNFAC,DBNSLV,DBSPVD,XERROR
'***END PROLOGUE DBINT4
'
'
Dim I As Integer
Dim IFLAG As Integer
Dim ILB As Integer
Dim ILEFT As Integer
Dim IT As Integer
Dim IUB As Integer
Dim IW As Integer
Dim IWP As Integer
Dim J As Integer
Dim JW As Integer
Dim NDM As Integer
Dim NP As Integer
Dim NWROW As Integer
Dim TOL As Double
Dim TXN As Double
Dim TX1 As Double
Dim VNIKX(,) As Double
Dim WDTOL As Double
Dim WORK() As Double
Dim XL As Double
Dim D1MACH() As Double
'Dim X(1), Y(1), T(1), BCOEF(1), W(5, 1), VNIKX(4, 4), WORK(15)
'***FIRST EXECUTABLE STATEMENT DBINT4
WDTOL = D1MACH(4)
TOL = Sqrt(WDTOL)
If (NDATA < 2) Then GoTo 200
NDM = NDATA - 1
For I = 1 To NDM
If (X(I) >= X(I + 1)) Then GoTo 210
10: Next I
If (IBCL < 1 Or IBCL > 2) Then GoTo 220
If (IBCR < 1 Or IBCR > 2) Then GoTo 230
If (KNTOPT < 1 Or KNTOPT > 3) Then GoTo 240
K = 4
N = NDATA + 2
NP = N + 1
For I = 1 To NDATA
T(I + 3) = X(I)
20: Next I
Select Case KNTOPT
Case 1 : GoTo 30
Case 2 : GoTo 50
Case 3 : GoTo 90
End Select
' SET UP KNOT ARRAY WITH MULTIPLICITY 4 AT X(1) AND X(NDATA)
30: REM
For I = 1 To 3
T(4 - I) = X(1)
T(NP + I) = X(NDATA)
40: Next I
GoTo 110
' SET UP KNOT ARRAY WITH SYMMETRIC PLACEMENT ABOUT END POINTS
50: REM
If (NDATA > 3) Then GoTo 70
XL = (X(NDATA) - X(1)) / 3.0
For I = 1 To 3
T(4 - I) = T(5 - I) - XL
T(NP + I) = T(NP + I - 1) + XL
60: Next I
GoTo 110
70: REM
TX1 = X(1) + X(1)
TXN = X(NDATA) + X(NDATA)
For I = 1 To 3
T(4 - I) = TX1 - X(I + 1)
T(NP + I) = TXN - X(NDATA - I)
80: Next I
GoTo 110
' SET UP KNOT ARRAY LESS THAN X(1) AND GREATER THAN X(NDATA) TO BE
' SUPPLIED BY USER IN WORK LOCATIONS W(1) THROUGH W(6) WHEN KNTOPT=3
90: REM
For I = 1 To 3
T(4 - I) = W(4 - I, 1)
'If 1 >= I - 1 Then max0 = 1 Else max0 = I - 1
JW = Max(1, I - 1)
IW = I + 2 Mod 5 + 1
T(NP + I) = W(IW, JW)
If (T(4 - I) > T(5 - I)) Then GoTo 250
If (T(NP + I) < T(NP + I - 1)) Then GoTo 250
100: Next I
110: REM
'
For I = 1 To 5
For J = 1 To N
W(I, J) = 0.0
120: Next J
130: Next I
' SET UP LEFT INTERPOLATION POINT AND LEFT BOUNDARY CONDITION FOR
' RIGHT LIMITS
IT = IBCL + 1
Call DBSPVD(T, K, IT, X(1), K, 4, VNIKX, WORK)
IW = 0
If (Abs(VNIKX(3, 1)) < TOL) Then IW = 1
For J = 1 To 3
W(J + 1, 4 - J) = VNIKX(4 - J, IT)
W(J, 4 - J) = VNIKX(4 - J, 1)
140: Next J
BCOEF(1) = Y(1)
BCOEF(2) = FBCL
' SET UP INTERPOLATION EQUATIONS FOR POINTS I=2 TO I=NDATA-1
ILEFT = 4
If (NDM < 2) Then GoTo 170
For I = 2 To NDM
ILEFT = ILEFT + 1
Call DBSPVD(T, K, 1, X(I), ILEFT, 4, VNIKX, WORK)
For J = 1 To 3
W(J + 1, 3 + I - J) = VNIKX(4 - J, 1)
150: Next J
BCOEF(I + 1) = Y(I)
160: Next I
' SET UP RIGHT INTERPOLATION POINT AND RIGHT BOUNDARY CONDITION FOR
' LEFT LIMITS(ILEFT IS ASSOCIATED WITH T(N)=X(NDATA-1))
170: REM
IT = IBCR + 1
Call DBSPVD(T, K, IT, X(NDATA), ILEFT, 4, VNIKX, WORK)
JW = 0
If (Abs(VNIKX(2, 1)) < TOL) Then JW = 1
For J = 1 To 3
W(J + 1, 3 + NDATA - J) = VNIKX(5 - J, IT)
W(J + 2, 3 + NDATA - J) = VNIKX(5 - J, 1)
180: Next J
BCOEF(N - 1) = FBCR
BCOEF(N) = Y(NDATA)
' SOLVE SYSTEM OF EQUATIONS
ILB = 2 - JW
IUB = 2 - IW
NWROW = 5
IWP = IW + 1
Call DBNFAC(W(IWP, 1), NWROW, N, ILB, IUB, IFLAG)
If (IFLAG = 2) Then GoTo 190
Call DBNSLV(W(IWP, 1), NWROW, N, ILB, IUB, BCOEF)
Exit Sub
'
'
190: REM
Call XERROR(" DBINT4, THE SYSTEM OF EQUATIONS IS SINGULAR", 45, 2, 1)
Exit Sub
200: REM
Call XERROR(" DBINT4, NDATA IS LESS THAN 2", 30, 2, 1)
Exit Sub
210: REM
Call XERROR(" DBINT4, X VALUES ARE NOT DISTINCT OR NOT ORDERED", 50, 2, 1)
Exit Sub
220: REM
Call XERROR(" DBINT4, IBCL IS NOT 1 OR 2", 28, 2, 1)
Exit Sub
230: REM
Call XERROR(" DBINT4, IBCR IS NOT 1 OR 2", 28, 2, 1)
Exit Sub
240: REM
Call XERROR(" DBINT4, KNTOPT IS NOT 1, 2, OR 3", 34, 2, 1)
Exit Sub
250: REM
Call XERROR(" DBINT4, KNOT INPUT THROUGH W ARRAY IS NOT ORDEREDPROPERLY", 60, 2, 1)
End Sub
|
|
|
|
|
Hi,
I am a C# guy, my knowledge of VB is limited, but I have had a long Fortran experience.
My code examples will be very limited and in C#, I trust you will understand them and know
the VB equivalent.
I will not give you ready answers to your two problems, but I will present the basic
facts you need to solve them.
I am not surprised by the problems you are having. Do you know Fortran at all ? Here are
some of its peculiarities:
- there is a "named COMMON" statement that allows to pass data to other parts
of the program; all COMMON statement with the same name map one on top of the other
(as if they get added to all parameter lists). Since they can use different names, types
and dimensions in different instances, dirty tricks can be implemented that are
quite the opposite of OO, and impossible to mimic in any CLR language.
Your code does not seem to have COMMON statements tho.
- array indexes are either 0-based or 1-based, you can somehow choose, I think the default
is 1-based. AFAIK all CLR languages have 0-based indexing. So be careful about it.
- there is no index checking on arrays, so you can declare an array with 100 elements,
fill them, then read beyond element 100 (and get whatever happens to be there).
- as a consequence you can pass an array A(100) to a subroutine that accepts it as B(1);
then read/write B(1) actually accesses A(1), and B(100) accesses A(100).
Conclusions:
- array index base may cause problems
- array passing must be revisited
- I doubt you can just adapt the syntax, get the compiler happy and expect the code to
be correct. I think that would we very naive and overly optimistic. I promise you will
spent a lot of time to figure out why the program throws all those exceptions, and later
on probably also why the results are just plain wrong.
I would suggest a different approach, actually I list three of them:
1. look for a .NET compatible Fortran compiler, buy and use it (IIRC I have seen one
a couple of months ago); this would not be my choice tho, unless there is quite a lot
of vested interest in Fortran code (a couple of subroutines would not convince me).
And even then you should somehow compare the original Fortran language used, and
the one implemented in the new compiler (the language did evolve quite a lot, much
more so than C or C++ did).
2. make sure you have a working Fortran environment (does not have to be .NET, does not
even have to be on a PC) so you can experiment with parts of
the original code, or some small pieces of new code; try to create VB code
to perform the same functionality in the same way as much as possible.
This means taking care of a lot of remarks like the ones I made earlier.
Without a real knowledge of Fortran AND the algorithms in the subroutines, I dont give
this a high success probability.
3. look at the original Fortran code from a distance, read up on the references, try
to really understand the algorithms and then reimplement them in VB, without worrying about
the line-by-line equivalence. That is, ignore the Fortran code (or use it as pseudo-code
intended to illustrate the algorithms that interest you), then implement them.
This is the approach I would recommend; it does not spent much effort in the Fortran side,
instead you would learn about the application domain, and in the end get a modern
implementation (e.g. without all these nasty GOTO statements and labels).
Summary: whatever way you choose, it will be much more work than you probably anticipated,
and I recommend a completely different approach.
Hope this helps.
|
|
|
|
|
Notice your Sub's last parameter declaration:
Sub DBINT4(... , ByVal W(,) As Double)
You told it to expect a 2 dimension array of Double's, but in your method calls somewhere else in your code, you passed in a single Double value for that parameter, not an array.
|
|
|
|
|
Yes, indeed, and that is perfectly valid in Fortran; rows (or was it columns ? dont remember)
follow one another.
And I expect it is hard to do the same in any CLR language; that's one more reason to
start from scratch.
|
|
|
|
|
OK I'm about to pull my hair out on this one. I've got a socket created that sends a network stream of data from a listview to an open port.
It works great!! I'm getting ACK's back from the server with no problem. I can even send multiple messages at a time. HOWEVER...
If I highlight one item and send it... then highlight another item immediately afterwards and send it... I get a connection refused.
If I send one item, wait about 7-8 seconds... then send another one... I'm fine.
Please review my code and tell me where I'm going wrong!! Thanks in advance!!
Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click
Dim ListViewSelect As ListView.SelectedListViewItemCollection = Me.ListView1.SelectedItems
Dim item As ListViewItem
Dim selecteditem As String
Dim selecteditemhex As String = Chr(11)
Dim SelectedCount As String
Dim tcpClient As New System.Net.Sockets.TcpClient
Try
tcpClient.Connect("10.1.1.94", 8444)
'tcpClient.Connect("127.0.0.1", 8444)
Catch ex As Exception
MessageBox.Show(Err.Description)
End Try
SelectedCount = ListViewSelect.Count()
Select Case SelectedCount
Case 0
MessageBox.Show("Please select 1 item", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Case Is > 0
For Each item In ListViewSelect
selecteditem = selecteditemhex + LTrim(item.SubItems(4).Text)
Dim networkStream As NetworkStream = tcpClient.GetStream
If networkStream.CanWrite And networkStream.CanRead Then
Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes(selecteditem)
networkStream.Write(sendBytes, 0, sendBytes.Length)
Dim bytes(tcpClient.ReceiveBufferSize) As Byte
networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize))
Dim returndata As String = Encoding.ASCII.GetString(bytes)
MessageBox.Show("Host returned: " + returndata)
Else
If Not networkStream.CanRead Then
MessageBox.Show("cannot write data to this stream")
tcpClient.Close()
Else
If Not networkStream.CanWrite Then
MessageBox.Show("cannot read data from this stream")
tcpClient.Close()
End If
End If
End If
Next
End Select
btnSend.Text = "Sent"
tcpClient.GetStream.Close()
'tcpClient.Close()
End Sub
|
|
|
|
|
Hi,
I can not tell what is wrong just by looking.
One thing that strikes me is you have a lot of MessageBox statements, maybe one shows,
no matter what the flow in the method is. Wouldnt it then be better to close what needs to
be closed before you do a MessageBox ? (also it seems you sometimes do a GetStream.Close
after tcpCient.Close; dont know if that is wise). I think you could just set a string
variable (say "message") to the appropriate text, then go to the end of the method
where you close things and do the one and only MessageBox.Show(message).
If the above dont help, I would suggest you get more insight in the timing of your code:
what happens exactly when, and how long does it take. Therefore I would add some
timestamp logging statements.
Sorry but my examples will be in C# (I trust you'll know how to translate to VB):
private static void log(string s) {Console.WriteLine(DateTime.Now.ToString("mm:ss.fff ")+s);}
log("before connect");
tcpClient.Connect("10.1.1.94", 8444)
log("connected");
tcpClient.GetStream.Close()
log("tcp stream closed");
looking at the output you may discover that your code really takes several seconds to
execute, and maybe that there are opportunities to make it run a lot faster.
Hope this helps
|
|
|
|
|
By how many methods a class can be inherited in vb.net ?
|
|
|
|
|
Your question doesn't make any sense, but I'll take a guess at what you were trying to ask.
How many parent classes can a class inherit from? One and only one. But, a class can implement an unlimited number of Interfaces. Or do both at the same time.
|
|
|
|
|
I was confused too. I didn't know if he was asking how many instances of inheritance or how many methods to a class...
_____________________________________________
Flea Market! It's just like...it's just like...A MINI-MALL!
|
|
|
|
|
Since this is your first post I will not flame you, but you need to read the forum guidelines. Naming your message the same as the board gives us no clue as to what your problem is. You question may even be ignored in cases like this.
_____________________________________________
Flea Market! It's just like...it's just like...A MINI-MALL!
|
|
|
|
|
leckey wrote: question may even be ignored in cases like this
Which I am pretty much doing because the question makes no sense to me. What the frick is being asked here?
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
|
|
|
|
|
I'm not sure if he's asking how many methods to one class or how many instances of inheritance of one class or...oh hell I don't know either!
_____________________________________________
Flea Market! It's just like...it's just like...A MINI-MALL!
|
|
|
|
|
leckey wrote: oh hell I don't know either!
I may add that to my ever growing list of sigs
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
|
|
|
|
|