|
Hi all,
I have written this code........
On form1
button_click(........)handles......
dim f2 as form2
me.hide
f2.show
On form2
button_click(........)handles......
dim f3 as form3
me.hide
f3.show
Now on form3 I want to close form1.
How should I proceed ????
|
|
|
|
|
If Form1 is your startup object, you can't. If you close the startup object, you'll close your entire application.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi,
Thanks for your reply.
I just wanted to know how can I close a form from any other form ?
Hope you will again help me.
Thanks !
Suman Singh
|
|
|
|
|
Well, any forms spawned by Form1 will not know Form1 even exists, so there is no easy direct way to close any other form. You get around this problem adding a public field to your child forms where, when created, you pass a reference from the parent form to the child:
Dim myForm2 As New Form2
myForm2.ParentForm = Me
myForm2.Show()
Form2...
Public Class Form2
Public ParentForm As Form
Now, a new problem exists. If your child form tries to close it's parent, it's essentially killing itself in the process. Since the childs parent hold the only existing reference to the child, killing the parent kills the reference, which in turn kills the child.
So, the best method of having a form kill off any other form is to let the parent form manage all other open forms. Say if Form2 need to open Form3, Form2 would call back to Form1 (remember the reference from above?) to tell it to create Form3. Now, Form3 can also call be to Form1 to have it kill off Form2.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I am trying to perform a the find command in VB 6.0 where I can reference txtsearch.text value in the "Criteria" portion of the command. I want to type in the search criteria in a text box (txtTest) and then run the find command based on the value of this text box. See code below:
Dim mySearch as string
mySearch = txtTest.text 'where txtTest is an existing text box on my form.
On Error GoTo err_Report
With Adodc2.Recordset
Do Until .EOF
.Find ("Part_Number = '& mysearch &' ")
.MoveNext
Loop
End With
err_Report:
MsgBox Err.Description
-=BHBADZ=-
|
|
|
|
|
Hi There, code guru's =)
Can Anybody give me some hints on how to obtain a RAS (dail up internet connection) IP? Preferably without asking a DNS or WMI /Registry... Can Anybody point me in the right direction?;)
Thanx in advance!!
Dahool
If you make something idiotproof, someone else will make a better idiot.....
|
|
|
|
|
I have a data type is smalldatetime in the sql table, when I bind to my DataTable in VB.NET, when there is value in this column, the output is fine, but when it's NULL, then it gets error of the data type. In the sql, if it's string, I do ISULL(firstname, '') AS firstName inside sql query, then the output is fine, but I don't know how to convert the null smalldatetime. Is there any idea?
Lisa
|
|
|
|
|
|
I'm doing the OleDbDataReader in the vb appl.
THis is my code:
Dim OrderDate as date
Dim DataAdapter As New OleDbDataAdapter
Dim DataReader As OleDbDataReader
**connecting***
**sql query**
Select dateOrder from orderTable
***
DataReader = DataAdapter.SelectCommand.ExecuteReader()
Do While DataReader.Read()
OrderDate = DataReader.GetDateTime(0)
Loop
lblOrderDate.text = OrderDate
Where should I check the value of the column before using it?
If the dateOrder is Null, then this OrderDate = DataReader.GetDateTime(0) will get error.
THanks
Lisa
|
|
|
|
|
Okay - You are using a SqlDataReader, I assumed you had a dataset. By the way, if you are extracting data through a data reader then using a data adapter is redundant. Just build the SqlCommand object and use that.
Anyway, I've modified your code:
DataReader = DataAdapter.SelectCommand.ExecuteReader()
Do While DataReader.Read()
If Not DataReader.IsDBNull(0) Then
OrderDate = DataReader.GetDateTime(0)
Else
' Do something else because the data time is null
End If
Loop
Does this help?
Disclaimer - I typed this directly. There may be typos, syntax errors, etc.
My: Blog | Photos
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
|
|
|
|
|
Thanks! it works much better..
but there is one more thing.
how can I covert a Date type to a String type in vb?
The OrderDate is Date type, and I want it to be OrderDate= "" when it's NULL.
Lisa
|
|
|
|
|
|
it won't work when I do this...
Dim OrderDate as String
inside DataRead
If Not DR.IsDBNull(0) Then
orderDate = DR.GetDateTime(0).ToString("MM/dd/yyyy")
Else
orderDate = "" ***here is not working***
End If
any idea?
Lisa
|
|
|
|
|
Try
orderDate = IIf(IsDBNull(DR.GetDateTime(0)),"",DR.GetDateTime(0))
IIF(expression,Truepart,falsePart)
|
|
|
|
|
I tried your code, but the output is like this:
when the GetDateTime(0) has value, then it output empty, run time is fine, but if GetDateTime(0) is Null, then it has error "Specified cast is not valid"
do you know why?
thanks.
Lisa
|
|
|
|
|
I noticed that you are trying to put the datetime into a string variable.
Since your variable is not a date do not use GetDateTime.
orderDate = IIf(IsDBNull(Convert.ToString(DR(0))),"",Convert.ToString(DR(0)))
DR(0) should match the column or use the Column Name DR("COL_NAME")
Or try to use a non Date datatype
orderDate = IIf(IsDBNull(Convert.ToString(DR.GetValue(0))),"",Convert.ToString(DR.GetValue(0)))
play around with this.
|
|
|
|
|
Hi,
Just wondering if anyone knows of an easy way to create a wizard in vb.net ! I will be using it to lead the user through a series of questions and store their responses.
I am using Visual Studio Profesional 2003
Any help would be FAB !!!
Thanks
Martin
|
|
|
|
|
oops forgot to say that the wizard will need to be part of a web app.
|
|
|
|
|
Each page is going to ask a question or two. When the user clicks Submit, it calls back to the server where those values are stored (probably in a database associated with a session ID), then baced on those values, the page will have to chose the next page to redirect to. Where the same thing happens again... Until all your questions are answered.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
HI,
Yep that is exactly what i need . but i am still not sure of the best way to make it
Any help would be FAB !!
Thanks
Martin
|
|
|
|
|
I would like to know the code for adjusting the length of scrollbar if i want to shorten the length of the scrollbar and add a picture below the scrollbar. Currently i'm using AutoScroll function.
|
|
|
|
|
You don't. The scrollbar automatically adjusts itself depending on the length of the client area it controls.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I want to know how you can take global variables as strings in VB and write them into an existing pdf in the correct areas.
|
|
|
|
|
1. Global variables are a good sign that whoever wrote your code has no idea how to program
2. The location of variables has nothing to do with the ability to put them into a PDF
3. Unless you have created the PDF yourself, and it's not compressed, you'll need a third party tool to do this.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
I've created the pdf myself. What I want to do is put the variables into fields in the pdf. How do I do this?
|
|
|
|