|
Dear all,
Please tell me hoew can i open a new form from the previous form on clicking the button????
Regards
Pari
pari
|
|
|
|
|
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.Click<br />
<br />
Dim frm2 As New Form2<br />
frm2.Showdialog() <br />
end sub
Where button1 is the button that you click on to show the new form.
Where form2 is the name of the form you want to show.
Hope this helps
-- modified at 3:16 Monday 30th April, 2007
|
|
|
|
|
Please, never do this. If you call Show and not ShowDialog, the form should be a member variable.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"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 )
|
|
|
|
|
Christian Graus wrote: If you call Show and not ShowDialog, the form should be a member variable.
Oops my mistake.
I should of known better, I usually do use showdialog instead of show.
The code works though.
I'll just change it.
|
|
|
|
|
If you use ShowDialog, you also MUST call Dispose on the object when your done with the form. A resource leak will result if you don't.
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
Dear all, i'm an ASp.net developer but i'm workin on a desktop application
There is a requirement that is to open only one executable of the application and if the user tries to open another instance the application returns an error message
So how can i know that there is an instance already running?
One of the thoughts was to create a state variable saved in a text file or xml file but u cann't manage it 100% because maybe the OS restarted or the user closes the application by killing the process... So i think there is a better way by checking running prcesses in the memory.
Any key how can i implement that?
P.S. I'm using VB script on VS.net 2003
Best Regards
3ala2
|
|
|
|
|
I found the solution
It's by importing: System.Diagnostics
declaring a process array and use the GetProcess method
then looping throught the array and check if the process already exists...
Thanks anyway
Best Regards
3ala2
|
|
|
|
|
Try this :-
Dim currentProcess As Process = Process.GetCurrentProcess()<br />
Dim allProcesses() As Process = Process.GetProcessesByName(currentProcess.ProcessName)<br />
<br />
If allProcesses.Length > 1 Then<br />
Me.Opacity = 0.5<br />
MessageBox.Show("Program already running. This session will close")<br />
Application.Exit()<br />
End If
Steve Jowett
-------------------------
Sometimes a man who deserves to be looked down upon because he is a fool, is only despised only because he is an 'I.T. Consultant'
|
|
|
|
|
Thank u very much
I tired it and it works great
Thanx again
Best Regards
3ala2
|
|
|
|
|
I am developing a project to import a CSV format file and iinserting the data to Access Database.
After importing the data to a datagridview, i am inserting the data in datagridview to Database using a dataset(ds).
The insertion has to take place in two different tables (Candidate and Test).
The below code is what i am using for to serve the purpose.
'Updating Candidate table working properly
Private Sub ibt()
Dim i, id As Integer
Try
strSQL = "select ECCMID from Candidate where ECCMID=(select max(ECCMID) from Candidate)"
cnSQL = New OleDbConnection(ConnectionString)
cnSQL.Open()
cmSQL = New OleDbCommand(strSQL, cnSQL)
drSQL = cmSQL.ExecuteReader()
If drSQL.Read() Then
id = drSQL.Item("ECCMID") + 1
ph = id
Else
id = 7001
ph = id
End If
For i = 0 To ((ds.Tables("CInfo").Rows.Count) - 1)
strSQL = "insert into Candidate(ECCMID,CFName,CMName,CLName,MA1,MA2,MA3,City,State,Zipcode,Country) values(" & id & ",'" & ds.Tables("CInfo").Rows(i).ItemArray.GetValue(0) & "','" & ds.Tables("CInfo").Rows(i).ItemArray.GetValue(1) & "','" & ds.Tables("CInfo").Rows(i).ItemArray.GetValue(2) & "','" & ds.Tables("CInfo").Rows(i).ItemArray.GetValue(3) & "','" & ds.Tables("CInfo").Rows(i).ItemArray.GetValue(4) & "','" & ds.Tables("CInfo").Rows(i).ItemArray.GetValue(5) & "','" & ds.Tables("CInfo").Rows(i).ItemArray.GetValue(6) & "','" & ds.Tables("CInfo").Rows(i).ItemArray.GetValue(7) & "','" & ds.Tables("CInfo").Rows(i).ItemArray.GetValue(8) & "','" & ds.Tables("CInfo").Rows(i).ItemArray.GetValue(9) & "')"
cnSQL = New OleDbConnection(ConnectionString)
cnSQL.Open()
cmSQL = New OleDbCommand(strSQL, cnSQL)
cmSQL.ExecuteNonQuery()
id = id + 1
Next
drSQL.Close()
cnSQL.Close()
cmSQL.Dispose()
Catch Exp As OleDbException
MsgBox(Exp.Message, MsgBoxStyle.Critical, "Oledb Error")
Catch Exp As Exception
MsgBox(Exp.Message, MsgBoxStyle.Critical, "General Error")
End Try
End Sub
'Updating Test table its generating an error as "Unspecified error" after certain records are inserted. The error can struck at 2 record or at 90th record or at any point.
Private Sub ibt1()
Dim i, id1 As Integer
Dim s As String = "Null"
id1 = ph
Try
For i = 0 To ((ds.Tables("CInfo").Rows.Count) - 1)
s = IIf(IsDBNull(ds.Tables("CInfo").Rows(i).ItemArray.GetValue(11)), Nothing, ds.Tables("CInfo").Rows(i).ItemArray.GetValue(11))
strSQL = "insert into Test(ECCMID,TestID,Title,Series,TestD,Result) values(" & id1 & "," & 1 & ",'" & ds.Tables("CInfo").Rows(i).ItemArray.GetValue(10) & "','" & CInt(s) & "','" & ds.Tables("CInfo").Rows(i).ItemArray.GetValue(12) & "','" & ds.Tables("CInfo").Rows(i).ItemArray.GetValue(13) & "')"
cnSQL = New OleDbConnection(ConnectionString)
cnSQL.Open()
cmSQL = New OleDbCommand(strSQL, cnSQL)
cmSQL.ExecuteNonQuery()
id1 = id1 + 1
Next
Main.StatusLabel1.Text = "Records are successfully inserted"
MsgBox("The * file data has been imported to the database", MsgBoxStyle.Information, "Information")
drSQL.Close()
cnSQL.Close()
cmSQL.Dispose()
Catch Exp As OleDbException
MsgBox(Exp.Message, MsgBoxStyle.Critical, "Oledb Error")
Catch Exp As Exception
MsgBox(Exp.Message, MsgBoxStyle.Critical, "General Error")
End Try
End Sub
The problem is in the second fuction.
While Updating Test table its generating an error as "Unspecified error" after certain records are inserted. The error can struck at 2 record or at 90th record or at any point, no specific location.
Can any body help me with it, i just need a clue why the error is generated, Any problem with the code?
Plz help...
Jats
|
|
|
|
|
No-one is going to read all this code. Odds are, the problem is with the data, at the specific rows that are blowing up. Your code is at risk of SQL injections, perhaps one is happening by accident ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"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 )
|
|
|
|
|
Thankx for the help!!!
But i found the problem and solved it.
Thankx anyway!!!
Jats
|
|
|
|
|
And does this solution fix the SQL Injection Attack problem too?
|
|
|
|
|
How to read the volume label of drive X? For example, if the drive D has label "Linux", the function would return this name when called with parameter "D:".
|
|
|
|
|
|
Is there a better way to run a function every hour than enable a timer with tick value "3600000"? The problem is that when my application is running and this timer is enabled, Windows XP won't shutdown.
|
|
|
|
|
Set the timer for 1 minute. In the Tick event, check the time against the scheduled time. Simple as that.
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
Hi!
The error is
"Input past end of file" in the following section
' Load the file.
fnum = FreeFile
Open file_name For Input As fnum
whole_file = Input$(LOF(fnum), #fnum)
Close fnum
Though code is going fine with text files.
Thanks and Regards,
Virendra
|
|
|
|
|
virendra_007 wrote: Though code is going fine with text files.
A CSV file IS a text file. All CSV stands for is Comma Seperated Values.
virendra_007 wrote: whole_file = Input$(LOF(fnum), #fnum)
This is not a good method, as you've found out. Read each line from the file as a text line and process it, one line at a time:
Dim TextLine
Open "MyFile.CSV" For Input As #1
Do While Not EOF(1)
Line Input #1, TextLine
' parse up the line on comma's to get the values
Loop
Close #1
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
Hi! Dave,
Thanx for your kind co.operation.
Regards,
Virendra
|
|
|
|
|
how i will get value Member of the combobox when i am using datatable
jitendra
|
|
|
|
|
How do you mean ? You can set the valuemember property to the name of a column before databinding, is that what you need to know ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"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 )
|
|
|
|
|
dim con as new oledbconnection("connectionstring")
con.open
dim ds as new dataset
dim ad as new oledbdataadapter("query",con)
ad.fill(ds)
combobox1.displaymember=""
combobox1.valuemember=""
combobox1.datasource=ds.tables(0)
Hope this may help u.
|
|
|
|
|
How do I get javascript such as that listed below to be read in an ASP file before the command <%response.redirect "file.asp"%>
<%response.redirect "file.asp"%>
At the moment it just redirects to file.asp without executing the javascript.
If I remove <%response.redirect "file.asp"%> then the javascript is read, however when I add <%response.redirect "file.asp"%> the javascript is ignored and it just redirects to file.asp. Any ideas why this is happening?
|
|
|
|
|
Why do you have the response.redirect in server tags ? Why not do the redirect in javascript ?
I believe the issue is that the VBScript is executed first, to render the page, on the server. Then, the javascript runs on the client.
This question has nothing to do with VB or VB.NET, it belongs in the web dev forum.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"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 )
|
|
|
|