|
Forms in VB.NET are handled very differently than they were in VB6. The proper way to do this is Form2 should never know anything about, nor depend on the existance of, Form1.
Expose an event on Form2 that passes an Image back to any subscribers. When you click on the picturebox on Form2, Raise your event so Form1 will receive the Image and do whatever it needs to with the image, like pit in its own picturebox.
Form2:
Public Class Form2
Inherits System.Windows.Forms.Form
Public Event NewImage(ByVal i As Image)
Private Sub PictureBox1_Click(blah, blah) Handles PictureBox1.Click
RaiseEvent NewImage(PictureBox1.Image)
End Sub
End Class
Form1:
Public Class Form1
Inherits System.Windows.Form2.Form
Private Sub Button1_Click(blah, blah) Handles Button1.Click
Dim newForm2 As New Form2
AddHandler newForm2.NewImage, AddressOf form2newimagehandler
newForm2.Show()
End Sub
Public Sub form2newimagehandler(ByVal i As Image)
PictureBox1.Image = i
End Sub
End Class
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-- modified at 13:15 Sunday 19th February, 2006
|
|
|
|
|
THANKS you so much!!!~ it works~
|
|
|
|
|
We are porting an application from vb to vb.net. We are accessing a dll which is working fine in vb, but in vb.net it's not.
We need to pass a reference parameter to the function being accessed in the dll. This parameter is of type structure.
Pls can anyone guide how to pass a reference parameter to a structure type.
---Pravin.
|
|
|
|
|
I don't think so. Structure type cann't pass by ref.
It pass by value.
http://www.startvbdotnet.com/oop/structure.aspx
!alien!
-- modified at 1:27 Saturday 18th February, 2006
see also
http://www.codeproject.com/dotnet/Structures_VBNet.asp
|
|
|
|
|
we can pass structure type byref. but i don't know exactly how?
|
|
|
|
|
Just a guess:
Sub ValMethod(ByVal struct as SomeStructure(
'Here it's passed by value
)
Sub RefMethod(ByRef struct as SomeStructure(
'Now you can modify the structure because it's passed by reference
)
HTH!
"..Commit yourself to quality from day one..it's better to do nothing at all than to do something badly.."
-- Mark McCormick || Fold With Us! || Pensieve || VG.Net ||
|
|
|
|
|
this doesnt work
is it possible to to make this work?
Dim oleCmd As New OleDbCommand("SELECT RecNum " & _
"FROM Serial_Table", oleCon)
With oleCmd
lRecNum = .ExecuteReader.Item("RecNum").ToString
End With
tnx in advance
|
|
|
|
|
"This doesn't work" isn't a good explanation of the problem. What's it doing/not doing?? What are you expecting the code to do?
Also, there not enough of the code to "get it to work" or diagnose the problem. What is lRecNum defined as? What are you trying to do with the data?
About the only thing we could do is rewrite it and guess what you're trying to get it to do.
Dim oleDbConn As New OleDbConnection(connectionString
Dim oleDbComm As New OleDbCommand("SELECT RecNum FROM Serial_Table", oleConn)
Dim oleDbReader As OleDbDataReader
oleDbReader = oleDbComm.ExecuteReader()
While oleDbReader.Read() = True
' What are you doing with this data??????
...something...oleDbReader.GetInt32(0)
End While
oleDbReader.Close()
oleDbConn.Close()
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-- modified at 22:22 Friday 17th February, 2006
|
|
|
|
|
i was only wondering if it could be done
since there is "item" in executereader
ty
|
|
|
|
|
If WHAT could be done? You still haven't explained what your trying to do...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
rephrase:
is it possible to retrieve a data without using a datareader? (aside from executescalar)
is was wondering coz i saw "Item" in executereader
Dim oleCmd As New OleDbCommand("SELECT FldName " & _
"FROM TableName", oleCon)
With oleCmd
variable = .ExecuteReader.Item("FldName").ToString
End With
tnx in advance
-- modified at 20:46 Sunday 19th February, 2006
|
|
|
|
|
There are many ways to read a recordset. But, I'm repeating myself....What are you trying to do with this data???????? This will have a large impact on how you read it!!!!
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
honestly nothing
im only experimenting on the "item" i found in datareader
|
|
|
|
|
WHY DIDN'T YOU SAY THIS IN YOUR FIRST POST?!?!?!?!
Private Sub Button2_Click(blah, blah) Handles Button2.Click
Dim conn As New OleDbConnection("connectionString")
Dim comm As New OleDbCommand("SELECT * FROM MyTable", conn)
Dim dr As OleDbDataReader
conn.Open()
dr = comm.ExecuteReader(CommandBehavior.CloseConnection)
Dim ID As Integer
While dr.Read()
ID = dr.Item("TableColumnName")
End While
dr.Close()
End Sub
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
coz i didn't see it relevant
need not shout though
asking nicely
question wasnt still answered
might not be possible to to use the "item" in executereader
without using datareader in retreiving data
variable = executereader.item("fldname")
tnx anyway
|
|
|
|
|
It works. I just showed you how to use it.
You saw the Item property come up because the ExecuteReader method returns an OleDbDataReader object, which is the thing exposing the Item property.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi Guys!! Im trying to debug my Project in VB.NET 2005 having .NET Framework 2.0.
Im getting this weird Exception called MissingFieldException. It gives the following Message:
Field not found: System.Collections.Generic.KeyValuePair`2.Key'.
This is its Stack Trace if of Any Help:
at BTSharp.Client.TorrentDownloader.Seed()
at BTSharp.Client.TorrentDownloader.SeedingPoll() in C:\Documents and Settings\David\Desktop\BTSharp\2.0_source\btSharp\Client\TorrentDownloader.cs:line 817
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.runTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
PLZ if anybody has heard of this Exception or know how to tackle the Problem, Reply back. Thanx!!
Devraj Raut!!!
|
|
|
|
|
|
Trying to write a new service on our application server that sends and gets ftp files to a remote server via ftp.
written something like this in vb6 before but want to try .net since the framework is there.
Not the sure of the best way to set up the timer in .net? in vb6 i would attach a form with a timer and LOAD that form from the main. This would cause the service to fire on specific interval and check for new files.
Any recommendations? Can't even seem to get the LOAD frm to work.
thx
|
|
|
|
|
You should use the System.Timers.Timer[^] class.
Also, if you're making a Windows Service, then you should not be using forms.
-- modified at 16:18 Friday 17th February, 2006
|
|
|
|
|
Hi,
I'm trying to query some data into a listview.
When there is more than one row of data on the listview, how can I choose a specific row to be displayed into a new form?
-----------------------------------------
MyQuery1 = "SELECT Date, Author, Comments, Ratings FROM [books] WHERE [name] = '" & txtbooksname.Text & "' "
Do While Not rs1.EOF
Set anItem1 = lvwRvw.ListItems.Add(, , rs1(0) & vbNullString)
For m = 1 To rs1.Fields.Count - 1
anItem1.SubItems(m) = rs1(m) & vbNullString
Next m
rs1.MoveNext
Loop
------------------------------------------
example:
Row Date Author Comments Ratings
1 01/01/2005 aaa romance B-
2 01/02/2004 bbb advanture B+
3 01/02/2005 bbb advanture B
How can I get the details of row 2 to be displayed on a new form?
Thank you very much.
|
|
|
|
|
Take a look at the ListViews Items collection. Each listitem has a collection of subitems.
My Blog[^] FFRF[^]
|
|
|
|
|
|
Hi all,
Until now we used to send stored procedure and ask the client to execute it using SQL Query Analyzer. Now we are supposed to do that through vb.net. I have a vb.net form with a multiline text box. User selects the stored procedure that gets displayed in text box. Now how do I execute this stored procedure? I tried using command object but it does not work. Below is sample stored procedure:
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_InsertInCharges]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[sp_InsertInCharges]
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE PROCEDURE sp_InsertInCharges(@strRemarks As Varchar(100), @intTrnNr As Integer)
AS
declare @AccNr as int
declare @RoutingAccNr as int
declare @AmountDue as float
declare @strSQL as varchar(4000)
INSERT INTO Charges(ShipNr, ChargeID, Transaction_Nr, Sales_TrnNr, Partial_Sales_Nr, Charge_Date, Account_Nr,
Routing_Account_Nr, Cruise_Nr, Department_Code, Amount, IsTaxApplicable,
TaxType, TaxAmount, TaxPercent, Gratuity, Discount, Amount_Due, Charge_Type,
Payment_Type, Remarks, Bill_Number, User_Nr, Bill_Settled, Ex_Transaction_Nr,
ExcursionID, Event_Source,SettlementStatus)
SELECT ShipNr, ChargeID, Transaction_Nr, Sales_TrnNr, Partial_Sales_Nr, Charge_Date, Account_Nr,
Routing_Account_Nr, Cruise_Nr, Department_Code, Amount, IsTaxApplicable,
TaxType, TaxAmount, TaxPercent, Gratuity, Discount, Amount_Due, Charge_Type,
Payment_Type, @strRemarks As remark, Bill_Number, User_Nr, Bill_Settled, Ex_Transaction_Nr,
ExcursionID, Event_Source,SettlementStatus FROM Charges
WHERE Transaction_Nr = @intTrnNr
Set @strSQL = 'Select Account_Nr, Routing_Account_Nr, Amount_Due into Chargestemp from Charges WHERE Transaction_Nr = ' + Cast(@intTrnNr as varchar)
Exec @strSQL
set @strSQL = '
Select Account_Nr, Routing_Account_Nr, Amount_Due into Chargestemp from Charges WHERE Transaction_Nr = ' + Cast(@intTrnNr as varchar)
Exec (@strSQL)
declare Charges cursor for
Select Account_Nr, Routing_Account_Nr, Amount_Due * -1 from Chargestemp
open Charges
fetch next from Charges into @AccNr, @RoutingAccNr, @AmountDue
while @@fetch_status=0
begin
IF @RoutingAccNr <> Null or @RoutingAccNr <> ''
EXEC sp_UpdateDepositLimit @AmountDue, @RoutingAccNr
ELSE
EXEC sp_UpdateDepositLimit @AmountDue, @AccNr
fetch next from Charges into @AccNr, @RoutingAccNr, @AmountDue
end
close Charges
DEALLOCATE Charges
drop table Chargestemp
DELETE FROM Charges WHERE Transaction_Nr = @intTrnNr
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
|
|
|
|
|
Dim conn As New SqlConnection
conn.ConnectionString = Session("ConnectionString").ToString
Dim cmd As New SqlCommand
cmd.Connection = conn
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandText = "dbo.yourProc"
Dim Prm1 As New SqlParameter("yourParam", SqlDbType.Int)
Prm1.Direction = ParameterDirection.InputOutput
cmd.Parameters.Add(Prm1)
Prm1.Value = Your Value
conn.Open()
cmd.ExecuteNonQuery()
conn.Dispose()
cmd.Dispose()
"People who never make mistakes, never do anything."
My Blog
|
|
|
|
|