Hello,
Can i call a sub from another sub?
I short i did this: -
'Addhandler to the textboxes
-
AddHandler TextField(i).MouseClick, AddressOf Mouse_Click
-
AddHandler TextField(i).KeyPress, AddressOf Text_Save
-
AddHandler TextField(i).LostFocus, AddressOf Text_Focus
-
AddHandler TextField(i).Disposed, AddressOf Text_Dispose
-
-
'Addhandler to the DeleteButton
-
AddHandler DeleteBtn(i).MouseHover, AddressOf Delete_Hover
-
AddHandler DeleteBtn(i).Click, AddressOf Delete_Click
-
AddHandler DeleteBtn(i).Disposed, AddressOf Delete_Dispose
-
-
'Addhandler Picturebox
-
AddHandler ThumbPicturearr(i).MouseClick, AddressOf Thumb_Click
-
AddHandler ThumbPicturearr(i).MouseHover, AddressOf Thumb_Hover
-
AddHandler ThumbPicturearr(i).Disposed, AddressOf Thumb_Dispose
-
-
'AND THEN I CREATED THE SUBS
-
-
'FOR EXAMPLE
-
Sub Text_Dispose(ByVal Sender As Object, ByVal e As EventArgs)
-
-
Sender.Dispose()
-
-
End Sub
-
-
'AND I WANT TO CALL HEM FROM HERE:
-
-
Sub Delete_Click(ByVal Sender As Object, ByVal e As EventArgs)
-
-
-
-
If MessageBox.Show("Delete " & Sender.text & " from the database?" & vbCr & "(Pictures are not deleted!)", "Confirm", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) = Windows.Forms.DialogResult.OK Then
-
-
DeletSql = "DELETE FROM foto WHERE (id = " & Sender.Name & ")"
-
-
If UpdateDatabase(DeletSql) > 0 Then
-
-
Sender.Dispose()
-
Text_Dispose(Sender, e)
-
Delete_Dispose(Sender, e)
-
Thumb_Dispose(Sender, e)
-
MsgBox("Photo (" & Sender.Text & ") removed from the database")
-
-
End If
-
-
End If
-
-
End Sub
In short, when the photo has been deleted, the picturebox, the button and the textbox must be removed/disposed.
3 1671
Sure, why wouldn't you be able to?
This seems like it's one of those things that's faster to try than to ask...
Anyway, while you're here, since you are using VB.NET, you should be using .NET constructs. For example, MessageBox.Show() instead of MsgBox().
Hope that helps.
Yeah ok, but the msgbox is fine for here.
But the subs doesn't react. -
-
Text_Dispose(Sender, e)
-
Delete_Dispose(Sender, e)
-
Thumb_Dispose(Sender, e)
-
Only the button (Sender.Dispose()) disapears.
But the other (above) subs doesn't do anything!
Oh, I see.
Think about it this way. You are passing Sender from your first Sub to your next, and then calling Sender.Dispose(). So you're trying to dispose the same sender every time. You need to pass a reference to the actual object you are trying to dispose. For example: Text_Dispose(TextBox1, e) or whatever your textbox name is.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Tubby Tudor |
last post by:
What is the best way to call one python script from within another
python script? For example:
one.py finishes succesfully and calls two.py which finishes OK and then
calls three.py
Thanks...
|
by: JoeK |
last post by:
Hey all,
I am automating a web page from Visual Foxpro. I can control all the
textboxes, radio buttons, and command buttons using syntax such as:
...
|
by: Christian |
last post by:
From a not even newbie:
Without knowing much about Python (yet) I'm trying to install the CMS
Zope via FTP (with the well documented changes to make it work on an
Apache server).
By birth Zope...
|
by: seash |
last post by:
hi friends
I need to call an event (private void groupBox4_Enter(object sender, System.EventArgs e)) from an another event (private void Appexit_Closing(object sender,...
|
by: Wilfried Mestdagh |
last post by:
Hi,
I want to overload a constructor of a class. But I want to call the other
one from the second if called. I explain with code because of my english:
public class XMLConfig
{
public...
|
by: Daniel |
last post by:
Hi all,
Have any ideas for the above question?
for example, in pageA, i call pageB's buttonA.visible=false.
thank you in advance.
best regards,
GL
|
by: Kurt Van Campenhout |
last post by:
Hi,
I am trying to get/set Terminal server information in the active directory
on a windows 2000 domain. Since the ADSI calls for TS don't work until W2K3,
I need to do it myself.
I'm fairly...
|
by: mygoogleaccount |
last post by:
Hi,
may be someone could help me ?
i need to use cyrillic letters in a php application.
I changed everything to UTF-8 and it works fine. The only problem are
CYRILLIC SMALL LETTER ES...
|
by: mandible |
last post by:
I'm trying to call one stored procedure inside another.
I was wondering if this is possible
Some ideas I was toying with is putting the first stored procedure
inside of a temp table but haven't...
|
by: =?Utf-8?B?c2lwcHl1Y29ubg==?= |
last post by:
Hi
I am trying to see if I can call a Library remotely. The library contains a
Form
that I want to display then pass back some data to user that called this
form remotely.
I have it working...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |