|
Private Sub whatever_you_want(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
|
|
|
|
|
I’m still a bit confused.
I have the following sub that I want to be sure is executed whenever the form closes:
SaveData()
I have programmed the sub ‘SaveData()’ to execute under the ‘mnuExit_Click’ (and other areas).
My problem is that ‘SaveData()’ is executed once when ‘mnuExit_Click’ is executed and then again during frm1_cloising.
I assume that it is bad practice to just execute ‘SaveData()’ in ‘frm1_closing’ and in no other location.
Thanks
Brad
|
|
|
|
|
Brad Fackrell wrote:
I assume that it is bad practice to just execute ‘SaveData()’ in ‘frm1_closing’ and in no other location.
The reason why it's getting executed twice is because you execute it in the mnuExit handler AND your doing it again when the Closing event is fired. If you want to handle all possible ways of closing a form, then the Closing event is the way to go...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Dave Kreskowiak wrote:
If you want to handle all possible ways of closing a form, then the Closing event is the way to go...
Okay. I thought that would work but then I "second guessed" myself because I thought; Why add any sub routines under mneExit?
Thanks Dave.
|
|
|
|
|
Replace SaveData() in mnuExit_Click and all other locations (except frm1_closing) by Me.Close().
|
|
|
|
|
Works perfect! Thank you
Brad
|
|
|
|
|
Hi, I am having a problem with the drop down mode in a combo box. I have set up a combo box that allows the user to type values and the list will filter out and select the next closest item. It is a multicolumn, autocomplete combobox. The value member, text, and other properties can be found when the item exists in the list, but when the user types a value not found within the list, I get index 0 problems. I was wondering if anyone has any suggestions on how I can fix or get around this problem. Thank you.
|
|
|
|
|
I am rewriting a VBA excel funtion that has ranges in VB.NET
I have no clue how to do the ranges in vb.net (most likely a 2 D array).
The following is the VBA excel function that I am trying to rewrite.
strip(Today,EndDate1Yr,$L$120:$L$122,$A$20:$B$23,$E$4:$F$9)
today = startdate (date datatype)
enddate1yr = fordate (date datatype)
intraday = range
serial = range
standard = range
Does any one suggest me or share any code pointers that can help me to proceed.
thanks
nath
|
|
|
|
|
I'm trying to parse a text file using the .readline() method of streamreader. My problem is that my code (below) won't work with text files that have blank lines. It thinks this is an 'end of the file' statement. Is there something else i can test in the conditional statement besides "Do until strLine = Nothing" so that i can read even a blank line and read the file straight through to the 'real' end of file?
---------------------------
strLine = srdCurrent.ReadLine()
Do Until strLine = Nothing
strFile += strLine & CrLf
strLine = srdCurrent.ReadLine()
Loop
----------------------------
|
|
|
|
|
Try this example, it reads from a file (including blank lines) into a TextBox:
Dim file As New IO.StreamReader("c:\temp\test.txt")
While file.Peek > 0
TextBox1.Text += file.ReadLine() & vbCrLf
End While
file.Close()
Hope this helps
Tom
|
|
|
|
|
Hey it worked! Thanks!
jaspe
|
|
|
|
|
i would do it differently, instead of peeking into the file (which is generally not a good thing to do due to various reasons)
use this statement instead
while MyStramReader.BaseStream.Position < MyStramReader.BaseStream.Length<br />
...
should also work faster (i think...)
Fade (Amit BS)
|
|
|
|
|
Good suggestion! I'll give it a try, thanks!
jaspe
|
|
|
|
|
Hi,
Is there a way to format each line of text in a rich text box to be a different font at design time
|
|
|
|
|
No. When you set up the font property, it applies to all lines in rich text box. There´s no way you can do that.
|
|
|
|
|
im a vb6 programmer and im shifting right now to vb.net..i just want to know the counter part of my routine of saving in vb6 to vb.net using adapter and dataset..this is a combination of addnew and update..it goes like this..im made it very basic just to give you the scenario..
--routine in vb6 saving--
dim cn as adodb.connection
dim rs as new adodb.recordset
dim xsql as string
cn.open connectionstring
xsql="select * from table where field='" & txt & "'"
rs.open xsql,cn,....
if rs.eof then
rs.addnew 'if no records found
rs!id=txtid
end if
rs!lastname=txtlastname
rs!firstname=txtfirstname
rs.update
pls help if anyone has the idea..
|
|
|
|
|
Are you going to set up the connection in code or use the appropriate dataadapter? If by using the adapter, you would setup the adapter with the database you want to connect to(i.e. if using Access then use Jet 4.0) then generate the dataset for that dataadapter. Most of the time I just bind my textboxes in the databinding section of the property box. then to adda the record would go something like this:
'this adds new record to the dataset
Try
dim newrow as datarow = dataset.Tablename.newrow
newrow("lastname")=txtlastname.text
newrow("firstname")=txtfirstname.text
dataset.tablename.rows.add(newrow)
Catch ex as exception
messagebox.show(ex.tostring)
end try
'this update database based on the dataset
try
dataadapter.update(dataset, "Tablename")
catch ex as exception
messagebox.show(ex.tostring)
end try
|
|
|
|
|
How do we print a master detail form in VBNet without using Crystal report?
Any example in VBNet 2002:rolleyes :?
|
|
|
|
|
|
Hi all
I've following problem, i have an array of computer name (in LAN and not in LAN), all i want is get the domain name of specific computer (if the computer is in domain). For example, i've found a computer named "COMP1" which have controlled by a domain controller and i want to display the domain name of COMP1 (COMP1 is not in my LAN and is a internet computer which i've found by scanning IP).
I mentioned to use a function like that
Function GetDomain(ByVal sCompName As String) As String
'Do something here and get the domain name of sCompName and return to user
End Function
Is it a possible way to do that by programming with VB6?
Anyhelp might be very helpful
Thank alots!
.::LDLP::.
|
|
|
|
|
I'm using DataGridTableStyle to change the datagrid properties, but if it's using stored procedure, then it won't work, is there anybody knows why?
here is my code, when I run it, the datagrid headerText and width didn't change..
Dim DGTableStyle As New DataGridTableStyle
Dim textCol As New DataGridTextBoxColumn
grdAddPlan.TableStyles.Clear()
DGTableStyle.MappingName = "dbo.p_JobPlan"
textCol.MappingName = "EntityID"
textCol.HeaderText = " "
textCol.Width = 2
DGTableStyle.GridColumnStyles.Add(textCol)
textCol = New DataGridTextBoxColumn
textCol.MappingName = "ID"
textCol.HeaderText = "Plan ID"
textCol.Width = 30
DGTableStyle.GridColumnStyles.Add(textCol)
grdAddPlan.TableStyles.Add(DGTableStyle)
Lisa
|
|
|
|
|
I have written this code at page load and creating a dataset :
Dim cnn As MySqlConnection
cnn = New MySqlConnection ("SERVER=newserver;username=root;password=;DATABASE=new")
cnn.open()
Dim sql As String
sql = "select BillId, VenderID from tblbillMaster"
Dim dA As New MySqlDataAdapter(sql, cnn)
Dim DS As New DataSet
dA.Fill(DS, "tblBillMaster")
And I have added a Blank crystal Report in my project.
And I have added to parameter fields names: BillId , name
if my tblbillMaster have 5 rows then how these all rows
will display in Crystal REport in these two fields.
SoftWare Engineer
|
|
|
|
|
I am working on file based Messenger application (using VB.NET) in which i m using a Web Service where all my application functions are written. I have a list of users which i m desplaying in a treeview & refreshing this list every 5 seconds. I call a function from web service to get the latest list of online users. But i want to run this process in background using threads. But i m not able to do this.
Code is:
----------------------------------------------------------------------------
Private populate_userlist_thread As Threading.Thread
Private Sub RefreshUserList()
'This is my main function, here i m calling another function using thread.
populate_userlist_thread = New Threading.Thread(AddressOf PopulateUsers)
populate_userlist_thread.Start()
End Sub
'Here is the delegate
Delegate Sub GeneralDelegate()
Private invoker As GeneralDelegate
Private Sub PopulateUsers()
Dim msngr_serv_obj As MessengerService.MessengerFunctions
Dim users_dataset As DataSet
Dim i As Int32
Dim curr_node As TreeNode
Dim tree_node_collection As TreeNodeCollection
msngr_serv_obj = New MessengerService.MessengerFunctions
users_dataset = msngr_serv_obj.GetOnlineUsers
UsersTreeView.Nodes.Clear()
For i = 0 To users_dataset.Tables(0).Rows.Count - 1
If UsersTreeView.InvokeRequired = True Then
invoker = New GeneralDelegate(AddressOf RefreshUserList)
UsersTreeView.Invoke(invoker)
End If
curr_node = UsersTreeView.Nodes.Add(users_dataset.Tables(0).Rows(i).Item(0).ToString)
curr_node.ForeColor = Color.Green
Next
End Sub
----------------------------------------------------------------------------
But this code is not working fine. Can anybody plz help me. Or do u have any other solution to this problem.
Thanks
Sumit Domyan
Software Developer
ANALEC INFOTECH
|
|
|
|
|
you are invoking 'RefreshUserList' from within the 'PopulateUsers' method ?
that can't be good...
AND you should invoke ALL the GUI related methods by delegates as you did in
usersTreeView.invoke(Invoker) otherwise strange things happen.
Fade (Amit BS)
|
|
|
|
|
Thanks for reply amit.
Actually the whole problem is i m calling Refresh userlist function every 5 seconds. should i destroy the previous thread before calling the function or not.
Sumit Domyan
Software Developer
ANALEC INFOTECH
|
|
|
|