Calling a Script Object after remove instance index[0]
I have created a LiveCycle document that has a repeatable subform as url linked below. The form will not let me call a Script Object after removing an instance at index[0]. Regardless of the number of instances remaining. I use a script object to show and hide buttons. Adding an instance is not a problem. What to do?
Script on Delete Subform Button (Error):
xfa.form.recalculate(1);
this.resolveNode('fifteenSubform._CorrectiveActionWrapper').removeInstance(this.parent.ind ex);
if (xfa.host.version < 8) {
//deleteing a [0] index seems to create a problem for executing the function in this Script Object
SOremove.fxremove();
https://files.acrobat.com/a/preview/03389d79-9020-45d9-ba4f-fb4cbdc21f77
Hi,
What seems to happen when you remove a form object that has code that is currently executing is that it can't find the next line. You might want to put all your code in the script object.
so in the click event you have;
SOremove.fxremove(this);
Then your script object will start
function fxremove(button) {
button.resolveNode('fifteenSubform._CorrectiveActionWrapper').removeInstance(button.parent.index);
if (xfa.host.version < 8) {
xfa.form.recalculate(1);
console.println("The SOremove.fxremove fired");
Regards
Bruce
Similar Messages
-
I'm having some trouble calling a function with arguments froma a radio button click event in the main form. How can this be done?
This is the way i'm trying to do this now:
-Script Object code (path: xfa.form.variable.fun1):
function ex1(var1,var2){....}
-Call from the radio button click event:
xfa.form.form1.variable.fun1.ex1(var1,var2)
Thanx!Hi,
What seems to happen when you remove a form object that has code that is currently executing is that it can't find the next line. You might want to put all your code in the script object.
so in the click event you have;
SOremove.fxremove(this);
Then your script object will start
function fxremove(button) {
button.resolveNode('fifteenSubform._CorrectiveActionWrapper').removeInstance(button.parent.index);
if (xfa.host.version < 8) {
xfa.form.recalculate(1);
console.println("The SOremove.fxremove fired");
Regards
Bruce -
Invalid Objects after remove Developer Environment
Hello,
after remove APEX Developer Environment I found some invalid View and Synonyms.
Views is okay, table no more exist an the synonym for this view.
DROP PACKAGE FLOWS_030100."APEX_MIG_PROJECTS_UPDATE";
DROP VIEW FLOWS_030100."APEX_MIGRATION_REV_TABLES";
DROP VIEW FLOWS_030100."APEX_MIGRATION_REV_QUERIES";
DROP VIEW FLOWS_030100."APEX_MIGRATION_REV_RPTS";
DROP VIEW FLOWS_030100."APEX_MIGRATION_REV_FORMS";
DROP VIEW FLOWS_030100."APEX_MIGRATION_PROJECTS";
DROP VIEW FLOWS_030100."APEX_MIGRATION_ACC_RPTS";
DROP VIEW FLOWS_030100."APEX_MIGRATION_ACC_FORMS";
DROP VIEW FLOWS_030100."APEX_MIGRATION_ACC_TABLES";
DROP VIEW FLOWS_030100."APEX_MIGRATION_ACC_PROJECTS";
DROP VIEW FLOWS_030100."APEX_MIGRATION_ACC_QUERIES";
drop PUBLIC SYNONYM APEX_MIG_PROJECTS_UPDATE;
drop PUBLIC SYNONYM APEX_MIGRATION_PROJECTS;
drop PUBLIC SYNONYM APEX_MIGRATION_ACC_PROJECTS;
drop PUBLIC SYNONYM APEX_MIGRATION_ACC_TABLES;
drop PUBLIC SYNONYM APEX_MIGRATION_ACC_FORMS;
drop PUBLIC SYNONYM APEX_MIGRATION_ACC_RPTS;
drop PUBLIC SYNONYM APEX_MIGRATION_ACC_QUERIES;
drop PUBLIC SYNONYM APEX_MIGRATION_REV_FORMS;
drop PUBLIC SYNONYM APEX_MIGRATION_REV_RPTS;
drop PUBLIC SYNONYM APEX_MIGRATION_REV_QUERIES;
drop PUBLIC SYNONYM APEX_MIGRATION_REV_TABLES;
But this 5 Synonyms I don't understand. Can anybody explain me this
PUBLIC SYNONYM APPLICATION_AUTHENTICATION
PUBLIC SYNONYM WWV_FLOW_LOOKUP_TABLES
PUBLIC SYNONYM WWV_FLOW_WEB_SERVICES
PUBLIC SYNONYM WWV_FLOW_REWRITE_QUERY
PUBLIC SYNONYM WWV_CREATE_FORUM_DEMO_SCRIPT
Bye
DanielDaniel,
Those 5 public synonyms are not used in 3.1. You can drop them if you like.
Scott -
Is it possible to rearrange the elements in a List after removing indexes?
Hello,
I am hoping someone can help me out w/a question.
I have a list
List<String> Labels = new ArrayList<String> ();and I add 3 elements in the list
labels.add("one"); //index 0
labels.add("two"); //index 1
labels.add("three"); //index 2Later on in the program I remove 2 indexes,
labels.remove(0);
labels.remove(2);When i try to iterate through labels it throws
Exception in thread "AWT-EventQueue-0" java.lang.IndexOutOfBoundsException: Index: 1, Size: 1I perfectly understand the error. My question is this: after removing the indexes, how can i rearrange the list so that the one element that is left (currently at index 1) is set at index 0 so that it doesn't throw an exception ? is this doable ?
Thanks very much for your help!!va97 wrote:
Hello,
I am hoping someone can help me out w/a question.
I have a list
List<String> Labels = new ArrayList<String> ();and I add 3 elements in the list
labels.add("one"); //index 0
labels.add("two"); //index 1
labels.add("three"); //index 2Later on in the program I remove 2 indexes,
labels.remove(0);
labels.remove(2);
This doesn't work!
Before those call the List looks like this:
[one, two, three].
After you call remove(0), it will look like this:
[two, three]
Now, when you try to call remove(2), it will throw an IndexOutOfBoundsException, as there is nothing at index 2 anymore.
I perfectly understand the error. My question is this: after removing the indexes, how can i rearrange the list so that the one element that is left (currently at index 1) is set at index 0 so that it doesn't throw an exception ? is this doable ?I'm afraid you don't understand the error message correctly, since then your question would be different.
The error message says "you tried to access something at index 1, but this list only is of size 1". This means that the only valid index at that moment is 0. -
Calling a script (a mighty pickle).
Okay,
So I am trying to develop a plug-in using flex and patchpanel as the UI. The problem is that I need the plug-in to listen for a save event and run when the user saves their document. As far as I know, that can't be done with extendScript. SO, I thought I'd just make a plug-in that has a save event handler and then calls my script, but after some research it seems like that might be impossible... Is it?
Any other ideas? Can I make a dialog with ADM that is dynamic? Like if I wanted it to add fields based on other conditions?
Thanks for reading.
-BillWe have a fellow here who's beeing trying to get this working in a different SDK (but similar) and he had the following to say:
In his SDK, while communication between the plugin & the script/panel is supposed to be working, its not currently (Adobe's response is that its a bug that will be fixed for him sometime soon). I don't know what that means for whether or it would work in Illustrator. Illustrator has had this Flash/ExtentScript panel thing first so it may be that bugs in the other SDK are reflective of the state of AI CS4.
He thinks it should be possible to catch events from Illustrator via ExtendScript. He said something about registering for an event with his application in ExtendScript and he gets callbacks to his handler. So theoretically it should be possible to do in Illustrator somehow, since his application is based on what we have now in AI. -
Calling perl script from labview
Hi,
I have a perl script and I would like to call the perl script from Labview
anyone can help me with that?
I used system exec but I'm getting an error.
Anyone have a working example like calling a simple perl script from Labview.
Thanks
SL OngHi,
Thanks for the reply from everyone.
The attached is my code to call Perl script and after calling this, I need to query the Perl Script by sending command like @help. Do they have a way to query the Perl script by sending command like @help and get the return result.
I think Joseph you are right, but how do I get the return result if I invoke it in a separate dos session.
SL Ong -
Script object in fragment not working?
I have a fragment that contains a script object and a text field. The text field's initialize event handler calls a method in my fragment's script object. Everything works fine in preview mode of the fragment.
When I create a new file and use the fragment in that file, the initialize event handler in my fragment is invoked just fine, but the method I'm trying to call in the script object in the fragment never fires. What I have looks like this:
File
- fragment
Fragment
- script object "Foo"
- someMethod()
- xfa.host.messageBox("Foo");
- text field::initialize
- xfa.host.messageBox('hello');
- Foo.someMethod();
When I preview the fragment, I get "hello" and "Foo" message boxes.
When I preview the file, I only get the "hello" message box.
Is what I'm trying to do possible?
Thanks,
AndyWhen calling the script object that is embedded in the fragment you have to path specifically to that object. The scriptobjectName.method is not enough to find what you want. You would need FragmentName.ScriptObjectName.Method()
I tried it here and it worked.
You may want to use a script Fragment instead of using an embedded script object on a fragment. The script fragment would run in the form root context and would behave like you are expecting. -
"Object reference not set to an instance of an object" after view selection
Hello,
I have a Visual Studio LightSwitch project where I connect to a Oracle server and select a view as a new data source.
I get a error message "Object reference not set to an instance of an object" after selecting the Oracle view as a data source.
The Visual Studio Log shows me following details in the ActivityLog:
362 End package load [Visual Studio Explorers and Designers Package] {8D8529D3-625D-4496-8354-3DAD630ECC1B} VisualStudio 2011/09/05 12:17:58.258
*363 ERROR OracleConnectionUIControl.ProcessParentFormAcceptButtonClick - Exception opening the connection. Oracle Data Provider for .NET ORA-12560: TNS: Fehler bei Protokolladapter at Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx pOpoSqlValCtx, Object src, String procedure, Boolean bCheck) at Oracle.DataAccess.Client.OracleException.HandleError(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, Object src) at Oracle.DataAccess.Client.OracleConnection.Open() at Oracle.VsDevTools.DDEX.OracleConnectionProperties.Test() at Oracle.VsDevTools.DDEX.OracleConnectionUIControl.ProcessParentFormAcceptButtonClick(Object sender, EventArgs e) {D601BB95-E404-4A8E-9F24-5C1A462426CE} Oracle Developer Tools for Visual Studio 2011/09/05 12:18:05.652*
364 OracleVSGPkg.QueryClose - Begin Oracle Developer Tools VS Package Query Close {D601BB95-E404-4A8E-9F24-5C1A462426CE} Oracle Developer Tools for Visual Studio 2011/09/05 12:18:32.001
But this error ORA-12560 does not make any sense, because I have got a working connection to the Oracle server and can see tables and views.
Any ideas?
Environment:
Visual Studio 2010 SP 1
Windows Server 2008 R2
ODAC 11.2.0.2.40 Beta 2 for Entity Framework and LINQ to Entities
Regards
BenjaminHi, did you ever resolve this? I have the same problem.
Thanks,
Mike -
Handle to error object after calling the statement execute - SQLDBC
Topic related to SQLDBC inteface to MaxDB
=======================
In C++ while i was executing the statement
rc = stmt->execute("SELECT 'Hello SAPDB' from DUAL");
i could get a handle to the error object by a call to
stmt->error().getErrorText()
Now while using SQLDBC_C i am using
rc = SQLDBC_Statement_execute(stmt,tempstr,strlen(tempstr),encodAsciiType);
Now how do i get the handle to the error object ??
Call like the above one
fprintf(stderr, "Executed SQLDBC_Statement %s",stmt->error().getErrorText());
gives me compilation error:
error: invalid use of undefined type `struct SQLDBC_Statement'
/opt/sdb/programs/sdk/sqldbc/incl/SQLDBC_C.h:125: error: forward declaration of `struct SQLDBC_Statement'
Please Help and feel free to ask me if the question is not clear.
Regards
RajaSorry. This question doesn't make sense. So, i withdraw the question.
Basically what I had confused with earlier and got clarified now is:
Just like when we make a call to SQLDBC_Connection_connect and after that use the SQLDBC_Connection_getError to get a handle to the SQLDBC_ErrorHndl.
I wanted to know how should we get a handle to the SQLDBC_ErrorHndl after we have made a call to the SQLDBC_Statement_<function call>.
I got the answer after looking through the SQLDBC_C.h file. It will be SQLDBC_Statement_getError and similarly SQLDBC_PreparedStatement_getError.
Wish i could award myself the 10 points for solving the problem
Regards
Raja -
Functions in script objects not being recognized after certain point
Hi all,
I'm wondering if anyone has figured out why after normally about 300-500 lines of JavaScript in a Script Object, sometimes the functions near the end are no longer recognized by the XFA processor when referenced ("TypeError: Scripts.myFunction is not a function").
When reordered, further up the script object, they work as intended. The line at which it no longer recognizes functions also isn't always the same and I have worked with some script objects that have over 800 lines with all the functions still working.
I've tested in Designer 9 and 10, Reader 8 9 and 10.
Please at least let me know I'm not the only one. I knew of one other developer that had come across the same issue.
KyleThanks radzmar!
JSLint didn't find anything but it set me on the path towards looking for syntax errors. I deleted code in the script object line by line until I narrowed it down.
Turns out it is Regular Expression literals, in particular trying to escape (\) the metacharacters ($.{}[] etc).
For example, var reg = /\}/; should technically match any right-handed curly brace, which in fact it does! The function that it is in works perfectly but every function written below it is not recognized by the XFA processor. Just out of curiousity I tried reg = /\{\}/; which matches {} and all the functions below now are recognized. It seams as though, even though using the escape character is allowed in core JavaScript, the processor sees it as a syntax error because it's not terminated.
Anyways, the easy fix is of course using the RegExp constructor var reg = new RegExp("\\}"); but I'll miss the confidence I had using Regular Expression literals.
Thanks again for the nudge in the right direction.
Kyle -
How to call a function from a different script object?
Hi All,
Here is the scenario,
I have 2 script objects A and B .
In script object A i have a function called "funcA" and
in script object B i have a function called "funcB"
Now I want to call funcA from funcB which is not happening.
I tried doing
A.funcA();
inside funcB , but not able to access.
Kindly help.
Thanks
AbhiramHi Abhiram,
Just a guess - try including the root node/node reference above the script object.
form1.A.funcA();
What does the JavaScript Console say when firing the function? Are there any errors?
Your script objects can contain multiple functions. So you could move funcA() and funcB() into the same script object. This will make it easier.
Niall
Assure Dynamics -
Object after "FROM" keyword needed
hi Friends,
I have one question . I want to get the object in a variable in sql or pl/sql which is being queried against (the object after FROM key word)
For e.g. in the below statements
select *from v$active_session_history
select *from emp where empno=20;
How can i get v$active_session_history and emp ?
note: the object can be a view
One way is to REGEXP , but i am not too familiar with using it solve my problem.
Why i need it: I have 100s of sql texts and i want to get the object which these sqls are queried against and then use them for further activities.
10xHi Karthick Arp/BluShadow/#Nishe#/Dave Rabone Thanks for replying. Below are the details of what i want to achieve
I work on an OLTP application and check new queries which are doing FTS every week.
I have a script which is called from the cron. It runs a script every Saturday and checks v$sql_plan and v$sqlarea like below
+++++
operation = 'TABLE ACCESS'
AND options = 'FULL'
and upper(module) not like 'TOAD%' and upper(module) not like '%SQL%'
+++++
The script filters out those queries which i have already seen.
So i have the sql ids and few other details like rows in table etc.
For doing analysis i most of the times do the below:
1. TABLE
Check the indexes for understanding why it is not doing taking the indexes
2. VIEW
Check the metadata for the view as to what predicates would be better to avoid it going to FTS ,if possible.
I want to automate the above 2 steps
So what i want to do is get :
a. indexes list if the object is a table?
b. metadata for the view if the object is a view.
Below are answers to your questions
How about table or view that are part of join or scalar subquery or correlated subquery or subquery factoring etc.. Do you want them as well?
--Yes i want them all Are all your SQL statements simple selects? Or are they more complex, containing subqueries etc.?
--More complex And if the object is a view, do you need to know the base tables?
--No -
Disabled-/N/A-objects after catalog run
Hi Gurus,
After running the catalog script on my fresh instance I ended up with disabled constraints. Looking in the log file, I found (at least for the one shown below) that that is done on purpose. Does anybody know why this is done?
875 execute immediate 'alter table SYSTEM.LOGMNR_DICTSTATE$
876 add primary key (LOGMNR_UID) disable';
877
Also, a bunch of indexes have the status "N/A". What does that mean?
Thanx,
Lennert
ps: Below the complete list of anomilies:
OWNER TYPE NAME STATUS
SYSTEM CONSTRAINT SYS_C001041 DISABLED
SYSTEM CONSTRAINT SYS_C001043 DISABLED
SYSTEM CONSTRAINT SYS_C001044 DISABLED
SYSTEM CONSTRAINT SYS_C001045 DISABLED
SYSTEM CONSTRAINT SYS_C001046 DISABLED
SYSTEM CONSTRAINT SYS_C001047 DISABLED
SYSTEM CONSTRAINT SYS_C001048 DISABLED
SYSTEM CONSTRAINT SYS_C001049 DISABLED
SYSTEM CONSTRAINT SYS_C001050 DISABLED
SYSTEM CONSTRAINT SYS_C001051 DISABLED
SYSTEM CONSTRAINT SYS_C001052 DISABLED
SYSTEM CONSTRAINT SYS_C001053 DISABLED
SYSTEM CONSTRAINT SYS_C001054 DISABLED
SYSTEM CONSTRAINT SYS_C001055 DISABLED
SYSTEM CONSTRAINT SYS_C001056 DISABLED
SYSTEM CONSTRAINT SYS_C001057 DISABLED
SYSTEM CONSTRAINT SYS_C001058 DISABLED
SYSTEM CONSTRAINT SYS_C001059 DISABLED
SYSTEM CONSTRAINT SYS_C001060 DISABLED
SYSTEM INDEXES LOGMNR_I1ATTRCOL$ N/A
SYSTEM INDEXES LOGMNR_I1CCOL$ N/A
SYSTEM INDEXES LOGMNR_I1CDEF$ N/A
SYSTEM INDEXES LOGMNR_I1COL$ N/A
SYSTEM INDEXES LOGMNR_I1COLTYPE$ N/A
SYSTEM INDEXES LOGMNR_I1ICOL$ N/A
SYSTEM INDEXES LOGMNR_I1IND$ N/A
SYSTEM INDEXES LOGMNR_I1LOB$ N/A
SYSTEM INDEXES LOGMNR_I1OBJ$ N/A
SYSTEM INDEXES LOGMNR_I1TAB$ N/A
SYSTEM INDEXES LOGMNR_I1TABCOMPART$ N/A
SYSTEM INDEXES LOGMNR_I1TABPART$ N/A
SYSTEM INDEXES LOGMNR_I1TABSUBPART$ N/A
SYSTEM INDEXES LOGMNR_I1TS$ N/A
SYSTEM INDEXES LOGMNR_I1TYPE$ N/A
SYSTEM INDEXES LOGMNR_I1USER$ N/A
SYSTEM INDEXES LOGMNR_I2COL$ N/A
36 rows selected.If catalog.sql execution failed in between, then you should rerun the same.
After that try and recompile the invalid objects using utlrp.sql. -
DS-BW:Data load called from BW failed after Source System program_id change
Hi,
In my BW 7.0 instance I have Data Services 3.2 as source system.
Some time ago I have changed instance of Data Services I am connecting to - I just changed PROGRAM_ID in RFC connection parameters for that source system.
Since that time when I am trying to execute infopackage to call a job I am getting following error:
OCI call <OCISessionBegin> for connection <xxxxxxx> failed: <ORA-01017: inv
where <xxxxxx> is Oracle database connection name for Data Services instance I connected originally.
What can be reason for that?
Regards,
akIn Data Services Server Manager on DS box there were configurations for job server I connected originally and for the other job server. After removing original config it works fine.
ak -
I have a ListView displaying a collection of icons. The user can then select different icons (checkboxes) to do things like Copy or Delete.
Problem is, when I try to delete the actual file from the disk, I get an error telling me the file is "in use" ("vshost.exe", the VS runtime during testing).
I thought maybe it was because it still appeared in the window and was still in the ImageList, but even after removing it from both locations, I still get the error. My code:
Dim intCnt As Integer = 0
Do
ImageList2.Images.RemoveAt(intIconsChecked(intCnt)) ' Remove from collection.
lsvCollection.Items.RemoveAt(intIconsChecked(intCnt)) ' Remove from ListView window.
FileIO.FileSystem.DeleteFile(strIconPath & "\Icon" & Format(intCnt + 1, "00") & ".rsc") ' "+1" b/c Icons start with "01".
FileIO.FileSystem.DeleteFile(strIconPath & "\Icon" & Format(intCnt + 1, "00") & ".png") ' "In use" Error here.
".rsc" deletes just fine, so I know I'm deleting the correct file. Why does VS still think the file is still "in use"?
ThxMugsy,
Consider this as food for thought, even if you don't use it.
If you set it up right then you can control how it works. A reference is a reference and any left behind will cause you grief down the road when you try to delete things.
As an example, a simple class follows. It does *not* implement IDispose, although it does have a private shared Dispose method in it:
Public Class MyImages
Private _bmp As Bitmap
Private _name As String
Private _sourceFilePath As String
Private Sub New(ByVal bmp As Bitmap, _
ByVal name As String, _
ByVal filePath As String)
_bmp = bmp
_sourceFilePath = filePath.Trim
_name = name.Trim
End Sub
Public ReadOnly Property Bmp As Bitmap
Get
Return _bmp
End Get
End Property
Public ReadOnly Property Name As String
Get
Return _name
End Get
End Property
Public ReadOnly Property SourceFilePath As String
Get
Return _sourceFilePath
End Get
End Property
Public Shared Sub AddNew(ByRef miList As List(Of MyImages), _
ByVal imageFilePath As String)
Try
If miList Is Nothing Then
Throw New ArgumentNullException("The collection of MyImages cannot be null.")
ElseIf String.IsNullOrEmpty(imageFilePath) OrElse imageFilePath.Trim = "" Then
Throw New ArgumentException("The file path of the image cannot be null or empty.")
ElseIf Not My.Computer.FileSystem.FileExists(imageFilePath) Then
Throw New IO.FileNotFoundException("The file path of the image could not be located.")
Else
' Should do validation here that the file
' is actually an image but I'll not do this
' here...
Dim thisBMP As Bitmap = New Bitmap(imageFilePath)
miList.Add(New MyImages(thisBMP, GetFileNameWithoutExtension(imageFilePath), imageFilePath))
End If
Catch ex As Exception
Throw
End Try
End Sub
Public Shared Sub AddNew(ByRef miList As List(Of MyImages), _
ByVal imageFilePath As String, _
ByVal imageName As String)
Try
If miList Is Nothing Then
Throw New ArgumentNullException("The collection of MyImages cannot be null.")
ElseIf String.IsNullOrEmpty(imageFilePath) OrElse imageFilePath.Trim = "" Then
Throw New ArgumentException("The file path of the image cannot be null or empty.")
ElseIf Not My.Computer.FileSystem.FileExists(imageFilePath) Then
Throw New IO.FileNotFoundException("The file path of the image could not be located.")
ElseIf String.IsNullOrEmpty(imageName) OrElse imageName.Trim = "" Then
Throw New ArgumentException("The name of this image cannot be null or empty.")
Else
' Should do validation here that the file
' is actually an image but I'll not do this
' here...
Dim thisBMP As Bitmap = New Bitmap(imageFilePath)
miList.Add(New MyImages(thisBMP, imageName, imageFilePath))
End If
Catch ex As Exception
Throw
End Try
End Sub
Public Shared Sub Remove(ByRef miList As List(Of MyImages), _
ByVal imageFilePath As String, _
Optional ByVal removeFilePathAlso As Boolean = False)
Try
If miList Is Nothing Then
Throw New ArgumentNullException("The collection of MyImages cannot be null.")
ElseIf String.IsNullOrEmpty(imageFilePath) OrElse imageFilePath.Trim = "" Then
Throw New ArgumentException("The file path of the image cannot be null or empty.")
ElseIf Not My.Computer.FileSystem.FileExists(imageFilePath) Then
Throw New IO.FileNotFoundException("The file path of the image could not be located.")
Else
Dim findInstance As System.Collections.Generic.IEnumerable(Of MyImages) = _
From mi As MyImages In miList _
Where mi.SourceFilePath = imageFilePath
If findInstance.Count <> 1 Then
Throw New ArgumentException("The instance of MyImages specified by the" & vbCrLf & _
"image file path is not in the collection.")
Else
Dispose(findInstance.First)
If removeFilePathAlso Then
My.Computer.FileSystem.DeleteFile(findInstance.First.SourceFilePath)
End If
miList.Remove(findInstance.First)
End If
End If
Catch ex As Exception
Throw
End Try
End Sub
Private Shared Sub Dispose(ByVal instance As MyImages)
If instance IsNot Nothing AndAlso instance._bmp IsNot Nothing Then
instance._bmp.Dispose()
instance._bmp = Nothing
End If
End Sub
End Class
When you look through that, look specifically at the "Remove" method and in particular, look at the order in which things are done. That's the critical part in this.
I tested it with a simple form:
Two buttons, a checkbox, and a picturebox. I also copied a small folder full of image files to my desktop since I'll be deleting a file from it. Following is the code for Form1:
Option Strict On
Option Explicit On
Option Infer Off
Imports System.IO.Path
Public Class Form1
Private miList As New List(Of MyImages)
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
Dim desktop As String = _
My.Computer.FileSystem.SpecialDirectories.Desktop
Dim imgFolder As String = _
Combine(desktop, "Images")
PictureBox1.BorderStyle = BorderStyle.FixedSingle
For Each imgFilePath As String In My.Computer.FileSystem.GetFiles(imgFolder)
MyImages.AddNew(miList, imgFilePath)
Next
btn_RemoveFirstImage.Enabled = False
CheckBox_RemoveSourcePath.Enabled = False
End Sub
Private Sub btn_ShowFirstImage_Click(sender As System.Object, _
e As System.EventArgs) _
Handles btn_ShowFirstImage.Click
Try
If miList.Count >= 1 Then
With PictureBox1
.SizeMode = PictureBoxSizeMode.Zoom
.Image = miList(0).Bmp
End With
btn_RemoveFirstImage.Enabled = True
CheckBox_RemoveSourcePath.Enabled = True
End If
Catch ex As Exception
MessageBox.Show(String.Format("An exception was thrown:{0}{0}{1}", vbCrLf, ex.Message), _
"Exception", MessageBoxButtons.OK, MessageBoxIcon.Warning)
End Try
End Sub
Private Sub btn_RemoveFirstImage_Click(sender As System.Object, _
e As System.EventArgs) _
Handles btn_RemoveFirstImage.Click
Try
If miList.Count >= 1 Then
MyImages.Remove(miList, miList(0).SourceFilePath, CheckBox_RemoveSourcePath.Checked)
End If
PictureBox1.Image = Nothing
btn_RemoveFirstImage.Enabled = True
CheckBox_RemoveSourcePath.Enabled = True
Catch ex As Exception
MessageBox.Show(String.Format("An exception was thrown:{0}{0}{1}", vbCrLf, ex.Message), _
"Exception", MessageBoxButtons.OK, MessageBoxIcon.Warning)
End Try
End Sub
End Class
Running it is straightforward:
Now when I click to show the first one:
A different image is shown because that first one no longer exists - either in the collection or in the folder.
Closing/disposing all references is the key and the order matters.
Something to consider the next time around. :)
Still lost in code, just at a little higher level.
Maybe you are looking for
-
I want to get rid of all the old email without doing one email at a time. I don't want to have to edit and mark each email individually.
-
[OSB] Oracle Service Bus: select database DBadapter runtime
Suppose you have 2 databases DB1 and DB2 and both have the SCOTT scheme with the EMP table. The default way to gain access to the databases in the Oracle Service Bus (OSB) is by defining 2 database adapters and defining a business service on each ada
-
Is there any way to change the "cover" picture that is a associated with an album and displayed on the album list screen? I'm using ios7. Thanks
-
Need help installing Flash Player 10.1 in PC
When I go to the install Wizard, I get the prompts but do not get a "run" or "save" box. I currently have Flash Player 10.0 in my computer. I use Windows 7 in a HP PC. I'm also having problems using You Tube. Is this related?
-
What happened to the "Adobe RGB" choice that I had in the print module in the Beta Version?
My first experience with LIghtroom was through the Beta 3 version of the program. After much trial and error, I was finally able to produce acceptable prints by using the following settings: Printer Manages colours Profile - Adobe RGB Rendering Inte