|
|
Hi,
I tried this but it only reads one file in my directory ( the last file in my directory )
I want it to read all the files in my directory if it has the pharse and then output the value
<pre lang="vb">
Dim strFiles() As String = Directory.GetFiles("D:\Logs", "*.txt", IO.SearchOption.TopDirectoryOnly)
Dim strLines() As String
Dim sb As New StringBuilder
Dim intDm1 As Integer
Dim intSm5 As Integer
For j = 0 To strFiles.Length - 1
strLines = File.ReadAllLines(strFiles(j))
intDm1 = 0
intSm5 = 0
For k = 0 To strLines.Length - 1
If strLines(k).Trim.StartsWith("DM01") Then
intDm1 += 1
ElseIf strLines(k).Trim.StartsWith("SM05") Then
intSm5 += 1
End If
Next
sb.AppendLine(" Found DM01 " & intDm1 & " times, SM05 " & intSm5 & " times in the file """ & IO.Path.GetFileName(strFiles(j)) & """")
Next
TextBox4.Text = sb.ToString
Is there anyway to do that ?
|
|
|
|
|
You need to re-examine the parameter order in your call to GetFiles()
|
|
|
|
|
I cannot see anything obviously wrong with your code, so it should do what you want. I can only suggest you run it in the debugger to try and find out what is happening.
[edit]
I just ran this code and it works correctly. Your problem must lie elsewhere.
[/edit]
modified 23-Mar-18 5:52am.
|
|
|
|
|
There should be an exception handler in there, otherwise he'd have the original problem again
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
|
I thought there was something about an UnauthorizedAccessException or something; must be confused with another question.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
|
|
I AM TRYING TO READ ARABIC QR CODE I HAVE GOT STRING LIKE THIS:
"0E" & ChrW(2) & "!پù;ر-ً" & ChrW(5) & "üà1" & ChrW(18) & "ثV½›H$»سè" & vbBack & "“أK»V¢®؛" & ChrW(21) & "*" & ChrW(2) & " |" & ChrW(26) & "M§" & ChrW(18) & "uس/ءd'ق" & ChrW(15) & "•qw}َ" & ChrW(22) & "î" & ChrW(31) & "ِه" & ChrW(30) & ">›جWگ¢Kh" & vbCr
IF YOU PLEASE I WANT TO CONVERT IT TO REAL STRING
THANK YOU
|
|
|
|
|
Don't repost.
Don't shout.
What is a "real" string? Unicode? UTF-4096? And since when is a QR-code a localized string?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Hello !
I have a vb.net application on visual studio 2017.
I have set the shutdown mode "When last form close"
The problem is that when I close the last form , the application does not close completely.
It seems that something continue to execute even when the last form closes. On visual studio I have to press the stop button in order to exit.But even when I run the .exe outside Visual studio the situation is the same.
On my main form (this is the last form that is closed ) i've put on form's Formclosing event 2 instructions :(one of them )
Application.Exit or Environment.Exit. Sometimes one of these instructions are able to exit my application , but sometimes not.
What can i do ?
Thank you !
|
|
|
|
|
An "orphaned" (hidden) window can keep an app open.
The Application Windows (WPF) or OpenForms (Winform) collection has a reference to all open app windows / forms. I loop through it automatically on exit; closing anything I find.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
I've put this line on Main form FormClosed event :
MessageBox.Show(Application.OpenForms.Count) It return 0.
No forms are open , but still the application does not close at all. I have to press the stop button inside Visual studio.
|
|
|
|
|
What / where happens when you press Pause? Stack trace?
Also, put Debug.Writes here and there. A few asserts. Works wonders.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
When I try to close my main form , the application does not close. If I press pause , the stack trace is as following :
[Managed to Native Transition]
> System.Windows.Forms.dll!System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(System.IntPtr dwComponentID, int reason, int pvLoopData) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(int reason, System.Windows.Forms.ApplicationContext context) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoop(int reason, System.Windows.Forms.ApplicationContext context) Unknown
Microsoft.VisualBasic.dll!Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun() Unknown
Microsoft.VisualBasic.dll!Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel() Unknown
Microsoft.VisualBasic.dll!Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(string[] commandLine) Unknown
If I click Continue , the application continues to execute and does not exit (No forms are open ).
|
|
|
|
|
This could be causes by a lot of things.
- an instanced form
- a still working Thread / Task / Backgroundworker
- a still hooked and working Eventhandler
- ...
Have you checked that each dynamicly (that means coded by you) created Object is Disposed, created Handle is rejected ?
|
|
|
|
|
I'm not sure if I'm missing something but on a quick test, if you have placed
Application.Exit() in your FormClosing event like this:
Private Sub Form1_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
Application.Exit()
End Sub
then you will get recursion with another FormClosing() event. In my test, the app did not
hang, however I did get a repeated call to FormClosing(). If you break at Application.Exit() and
then step you will probably get an immediate recursive call.
If you are testing whether to close you should use the args:
Private Sub Form1_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
if somecondition = False then
{
e.Cancel = True ' Do not close
}
End Sub
Perhaps if you showed us your code it would be clearer.
|
|
|
|
|
It seems that the cause of the problem is a splash form that is first open when the application is started.This is the startup form.
This is just a form that ask for a username and password.
After the user enter the username and password and click the ok button ,I call the
Mainform.show()
and the Main form is open .On the Main form's Shown event , I close the splashform , with
Splashform.close
splashform.dispose
I've made a test , and I start the Main form on application start ( without opening the splashform ).So the Main form is the startup form.
In this case the application closes correctly. ( even without calling Application.exit or Environment.exit )
What can I do ?
|
|
|
|
|
I don't know how complicated your implementation is.
As a test I've done this.
Created Form1 and Form2
On Form1 Load I did this:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim splash As New Form2
If splash.ShowDialog() = Windows.Forms.DialogResult.Cancel Then
Application.Exit()
End If
End Sub
In Form2 I just implemented a button:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
DialogResult = Windows.Forms.DialogResult.Cancel
End Sub
When the application runs and Form1 loads, Form2 is displayed from the load procedure.
Clicking the button causes Form2 to close gracefully with (DialogResult = Cancel) and return Cancel in this example and the application does not open.
Returning OK allows the app to open.
Also I tried this instead of Load() and it works also:
Private Sub Form1_Shown(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Shown
Dim dlg As New Form2
If dlg.ShowDialog() = Windows.Forms.DialogResult.Cancel Then
Application.Exit()
End If
End Sub
It should be this simple. If this does not help I can only suggest that you make sure you don't
do any initialization of data or processes prior to verifying user through the splash screen.
That is, don't initialize anything in Load() if you are showing the splash screen in Shown().
Hope this helps.
-- modified 21-Mar-18 17:50pm.
|
|
|
|
|
Wrap the splashform with a using-clause. You can do the same for the Mainform. Also, when running from the IDE, close all forms as you normally do, go to the IDE, hit "pauze", and see how many threads are running.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
hello everyone i just want to know how put/create a table in the report..
like Mycroft Holmes said..
"You don't "print a DGV in CR". You create your report in CR with the layout you want (use a table in the report) and set the data source to the same data as your DGV. You then print the report, NOT the DGV."
i don't really know what to do. i am new in using the crystal report. pls i need help thank you so much.
modified 18-Mar-18 13:10pm.
|
|
|
|
|
You could go back to Mycroft's message and ask him for any further advice.
|
|
|
|
|
Richard MacCutchan wrote: ask him for any further advice and get some google foo.
I ditched CR more than a decade ago after it took them 14 months to respond to a support request. The astonishing thing was that they DID respond!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Did you consider panicking?
..or Googling for a tutorial on CR with VB.NET?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|