|
Well, it's obviously impossible to work that out, based on the code you have provided.
If you simplified the code, it would be easier to read. As it stands, you need to check each line carefully, instead of checking blocks that break up the logic.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Hi,
IMO your complex IF stuff is equivalent to:
If cad.EnfantInM1 Or cad.IsStdComponent Then
If doc.enfant = cad.enfant Then
WriteCreateToExcelDoc(cad, doc, exlLst)
ElseIf doc.draw <> cad.draw Then
WriteCreateToExcel00(cad, exlLst)
WriteCreateToExcelND(cad, exlLst)
EndIf
Endif
which may or may not be what you want.
Luc Pattyn
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
Hi everyone,
I would like to use the DataGridView Checkbox like a normal checkbox.
When someone clicks on it I want to get a checked or changed event and be able to test if the box was checked or unchecked. I have written the following code:
Private Sub DataGridView1_CurrentCellDirtyStateChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGridsearch.CurrentCellDirtyStateChanged
Dim checkboxcell As DataGridViewCheckBoxCell
Try
If (DataGridsearch.IsCurrentCellDirty) Then
DataGridsearch.CommitEdit(DataGridViewDataErrorContexts.Commit)
End If
If (checkboxcell.Value) Then
MsgBox("Display a message")
End If
Catch ex As Exception
End Try
End Sub
I think I am doing something wrong, Can someone suggest me a piece of code for this?
Thnaks.
|
|
|
|
|
1: please use the 'code block' tags for posting code
2:
jeshra279 wrote: If (checkboxcell.Value) Then
MsgBox("Display a message")
End If
Let me guess here your getting a nullreferenceexeption? (object not set to intance of an object (or something like that))
You declared the checkboxcell but never assigned it to the actual cell.
Further more to make this work you will have to implement some sort of test to check if the current cell is actually a checkboxcell otherwise you'll get some weird behavior if not errors.
3: for further post please post the error that your getting.
jeshra279 wrote: I think I am doing something wrong, Can someone suggest me a piece of code for this?
isn't exactly much to go on.
|
|
|
|
|
The CurrentCellDirtyStateChanged event handler manually raises the CellValueChanged event by calling the CommitEdit method.
Sub DataGridsearch_CurrentCellDirtyStateChanged( _
ByVal sender As Object, ByVal e As EventArgs) _
Handles DataGridsearch.CurrentCellDirtyStateChanged
If DataGridsearch.IsCurrentCellDirty Then
DataGridsearch.CommitEdit(DataGridViewDataErrorContexts.Commit)
End If
End Sub
So your code goes in the CellValueChanged event:
Public Sub DataGridsearch_CellValueChanged(ByVal sender As Object, _
ByVal e As DataGridViewCellEventArgs) _
Handles DataGridsearch.CellValueChanged
MsgBox("Display a message")
End Sub
|
|
|
|
|
I have found a good article at http://www.codeguru.com/columns/vb/article.php/c8459__2/ to build a ftp client. But I wanted to get everyone's input on what the best way of doing this in vb.net 2008.
What I am wanting to do is have 2 simple classes:
Class 1: Upload...
Class 2: Download...
All I want to pass into the class is the following:
IP Address
Port
Login
Password
Sending/Recieving File Location.
However I need the 2 classes to generate a form to show the user the stages of connection and progression of transmission.
Anyone have any insights on how I can go about this. Perhaps websites that can give me a working model to build from.
I could simply pass the command thru the command prompt but I would rather it be part of the main application and or .net framework if it is a must.
|
|
|
|
|
2 things:
JollyMansArt wrote: vb.net 2008
it's .net 2 or 3 or 3.5 or...
and Visual studio 2008
(just a small remark )
JollyMansArt wrote: Anyone have any insights on how I can go about this. Perhaps websites that can give me a working model to build from.
Depending on what you want there is a very easy way to do this:
my.Computer.network.uploadfile
my.computer.network.downloadfile
These 2 will work most of the time, besides that search the codeproject here to find more examples. There are tons of them.
|
|
|
|
|
JollyMansArt wrote: What I am wanting to do is have 2 simple classes:
Class 1: Upload...
Class 2: Download...
And I want my current project to be written in 5 lines of code. It's just not going to happen. The project requirements dictates the number of classes your should use, not your wishes.
JollyMansArt wrote: However I need the 2 classes to generate a form to show the user the stages of connection and progression of transmission.
These classes should not show forms at all. Their purpose should be limited to just what their title suggests, uploading and downloading a file. Any information that they need to report should be done through delegates, events and properties.
Why? You're developing this app with Windows Forms in mind. But, say you wanted to use those classes to write a Mobile app. The forms are completely different, so your classes would not be usable in a Mobile app.
|
|
|
|
|
Hello,
in my project I'm using a MDI window which holds a StatusStrip, containing Label and ProgressBar. When updating it from the BackgroundWorker of another form I get an InvalidOperationException saying (translated from German) that, before an OLE call could be processed, I'd have to set STAThread mode for the current thread.
After experimenting a lot, I'm a bit desperate... not knowing where to set STAThread mode. Does probably someone have an idea what's wrong in the following?
Here's my code:
' Call the delegate from the subform:
Private Sub BGWFileRead_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BGWFileRead.DoWork
CollectFrames(BGWFileRead, AddressOf MDIMain.ShowProgress) <------ here's where the exception is thrown
End Sub
Private Sub CollectFrames(ByVal bgw As BackgroundWorker, ByVal Handler As ShowProgressDelegate)
.. (other stuff) ..
If Handler IsNot Nothing Then
Dim ProcessMessage As String = New String(String.Format("Loading file {0} ({1} of {2})", thisFrame.FileToRead.Name, SoFar, Frames.Size))
Handler.Invoke(CLng(Frames.Size), SoFar, thisFrame.FileToRead.Name, ProcessMessage, ExecutionTime)
End If
End Sub
' Main MDI form:
Public Delegate Sub ShowProgressDelegate(ByVal Files As Long, ByVal TotalFiles As Long, ByVal filename As String, ByVal Message As String, ByVal Time As Integer)
Public Sub ShowProgress(ByVal Total As Long, ByVal SoFar As Long, ByVal file As String, ByVal Message As String, ByVal Timespan As Integer)
If Me.InvokeRequired Then
Dim SPdeleg As New ShowProgressDelegate(AddressOf ShowProgress)
Me.BeginInvoke(SPdeleg, New Object() {Total, SoFar, file, Message, Timespan})
Else
' actualize StatusStrip
Dim percent As Integer = CInt((SoFar / Total) * 100)
Me.StatusProgressBar.Value = percent
Me.StatusLabel.Text = Message
End If
End Sub
Thanks in advance for your input!
Michael
|
|
|
|
|
Hi,
you can set the appartment state for a thread using Thread.ApartmentState; you can do this only once per thread. You may not be able to do it for ThreadPool threads (and hence BackgroundWorkers), if so you will probably need an explicit Thread.
Luc Pattyn
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
Thanks for your answer, Luc.
I've used the same pattern in another project successfully, in which the 'ShowProgress' method is located in the same form (i.e. there's no MDI parent form holding the ProgressBar). The only difference now is that the BackgroundWorker is started in a subform, trying to call the same method which is located in the MDI parents class. Do you think that's what kills my approach? I wonder if there's just an error somewhere in my code - or some rule like 'you can place this and that only in a module' which I haven't stumbled upon yet...
|
|
|
|
|
I am unaware of anything special to MDI, ad I don't use MDI.
If your CollectFrames method throws, give it a huge try-catch, show the full exception.ToString(), and watch the line numbers to pinpoint the problem. Chances are the problem is in "do other stuff".
Luc Pattyn
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
Hello everybody,
I need some help with Parsing.
Here what I have to parse. I have to program it in VB MS Access:
'//*/Macro:911;Tests:#ADSLCustomerClass;Generates:146,147
BeginMacro911 ADSL 04 Fehlende Angaben, remplace Macro-326 cye 07.07.2003
Case_#ADSLCustomerClass
"002" : Mtext 146
"2" : Mtext 146
Else: MText 147
EndMacro911
The Real file has like 5000 more of these small texts I have to Parse...this is just 1 of the about 5000
Here what I have to do(I've done 1) and 2) of th first part , just don't know how to continue):
Description:
I need you to write a program using MS-Access which performs the following:
1) Display a “Switchboard” from which to select various functions. The switchboard will start with one button for one function called “Load Mac File”. The switchboard should be opened automatically when the access application is started.
2) Selecting Load Mac File from the switchboard should display a form where the user can browse to the “.mac” file to process.
a. The form should have a scrollable text box in which any progress or error messages are shown.
3) If the chosen .mac file can be opened:
a. Delete the contents of tblLoadableMacros
b. Read through the .mac file, parsing each macro and adding a new record about each to tblLoadableMacros
tblLoadableMacros should have the following fields:
• nID Integer, unique ID field, auto-generated
• nMacroNumber Integer, macro number. Unique value.
• sDescription Memo field. Macro description
• sTests Memo field, lists the values tested by the macro
• sGenerates Memo field, lists the macro text or values generated by the macro
• sMacro Memo field, contains the actual macro script
The attached .mac file is the file we want to parse. It is a text file, can be viewed with Notepad and contains macro script definitions. Here are two example scripts:
'//*/Macro:911;Tests:#ADSLCustomerClass;Generates:146,147
BeginMacro911 ADSL 04 Fehlende Angaben, remplace Macro-326 cye 07.07.2003
Case_#ADSLCustomerClass
"002" : Mtext 146
"2" : Mtext 146
Else: MText 147
EndMacro911
'//*/Macro:912;Tests:#ADSLCustomerClass;Generates:149,150
BeginMacro912 ADSL 01 neu Mindestvertragsdauer, remplace Macro-328 cye 07.07.2003
Case_#ADSLCustomerClass
"002" : Mtext 149
"2" : Mtext 149
Else: MText 150
EndMacro912
In the example of macro 911, your program should perform the following:
1) Read until you find a line which starts with “'//*/Macro:”. From that line of text, do the following:
a. Add a new record to tblLoadableMacros
b. Take the number after //*/Macro: and save it in the new record in nMacroNumber
c. Take the text between “Tests:” and the next semi-colon and store it in sTests. Trim white space.
d. Take the text after “Generates:” up to the end of line and store it in sGenerates. Trim white space.
2) Using the nMacroNumber parsed previously (e.g.: 911), read ahead until you find its BeginMacro line (e.g.: BeginMacro911). From THAT line, if there is any text after the BeginMacro keyword, do the following:
a. Take all text following the keyword (e.g.: BeginMacro911).
b. Remove any leading/trailing white space
c. Store the remaining text in sDescription
3) Scan all lines until you find the matching EndMacro keyword (e.g.: EndMacro912). Everything between (but not including) the BeginMacro and EndMacro lines is stored in sMacro
4) Store the new record.
5) Repeat from 1) until all macros have been read.
You’ll want to show error/progress messages as you go. Some examples:
• Parsing Macro 911…
• Stored Macro 911
• Error storing Macro 911: <error text>
• Did not find matching EndMacro911 keyword
• Warning: Macro 911 has no ‘Tests’ keyword.
• 127 Macros loaded. 5 Errors Encountered.
• Etc.
If someone could please help me I'd be so grateful, If you want to contact me through MSN Messenger (homedog6@hotmail.com) or Yahoo messenger (g_size18@yahoo.de) please ADD ME!
Hope this information helps
Regards Michael
|
|
|
|
|
Hi,
people on CodeProject are glad to offer advice, or help in solving a specific problem someone has with his code.
We do not just "help" by doing your work, i.e. the basic rule is: you do your work, we do ours. So do you have a specific question, instead of a project description?
Luc Pattyn
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
First off all thank you for replying!
Secondly, since I'm new here I didn't know
Well see I just don't know how to start!
as mention I have to parse that part of text but have no idea how to start.
If you could just like give me the beginning of how top start
|
|
|
|
|
ahhh yeah what i forgot to write was
in the first message it shows:
I need you to program...
I didn't mean you as in YOU GUYS
it's an E-Mail from my boss and he was referring that YOU to ME
|
|
|
|
|
Hi,
you would need File.OpenText, and String.StartsWith, and String.Substring, and many more.
I would stay away from Regex as this seems simple string manipulations.
Is this your first VB.NET app? Buy and study a book then.
Luc Pattyn
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
Hawkster18 wrote: If you want to contact me through MSN Messenger (homedog6@hotmail.com) or Yahoo messenger (g_size18@yahoo.de) please ADD ME!
First, this is never going to happen. Noone cares about your email addresses unless they're a spam bot.
Second, this is simple string manipulation. You can either look for those keywords and seperation characters in the line you get from the file or use a Regular Expression to do some of the parsing. Using a RegEx is MUCH harder to do if you don't know how to do simple string manipulations though. You know those functions, Mid, Left, Right??? Start with those to see what you can do.
This reeks of either homework or paid work. If it's paid work, refund the customers money and tell them you're not qualified to do this. If it's homework, you have to write the code. Noone here is going to write it for you.
|
|
|
|
|
I'm just asking for some help, since to chat online in a messenger is faster.
and I've been on yor site and haven't found what I've been looking for
|
|
|
|
|
You start by reading the file, line by line.
|
|
|
|
|
I just don't know how to parse, can't you like send me an example how to parse so I atleast have a start?
|
|
|
|
|
I don't have any examples.
All you're doing is grabbing a section of the line and comparing it to what you're looking for, like:
If Left(lineFromFile, 9) = "Something" Then
|
|
|
|
|
Hi All,
Can any one help me in how to format the command for Run method in script ?
i have tried different way in giving input for Run method but it doent work , can any one look into below code
Below code is doing a XCopy for source to destination .
Set oShell = CreateObject("WScript.Shell")
RetVal = oShell.Run("""C:\Program Files\XYZ\ABC\XCopy.exe"" ""C:\Program Files\XYZ\ABC\staging\Advance NDC\utility\vvv.txt"" ""C:\Program Files\XYZ\ABC\utility\vvv.txt"" / s / q / y", 2, True)
|
|
|
|
|
IT doesn work because you're putting spaces between the forward slashes and the commands.
You've got: (BTW: I hope you have XCOPY.EXE in that folder you specified!)
"...XCopy.exe" "C:\..." "C:\..." / s / q / y"
When it should be:
"...XCopy.exe" "C:\..." "C:\..." /s /q /y"
|
|
|
|
|
Thanks for pointing out .
|
|
|
|
|