|
This[^] may help, This will also[^] give you some pointers.
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
CCC Link[ ^]
Trolls[ ^]
|
|
|
|
|
http://www.developerfusion.com/tools/convert/csharp-to-vb/ - csharp to vb
http://www.blackbeltcoder.com/ - adohelper class c#
http://www.daniweb.com/software-development/csharp/code/216893 bubble sort
Read file
Dim fileContent As String = File.ReadAllText(filename)
Dim integerStrings As String() = fileContent.Split(New Char() {" "c, ControlChars.Tab, ControlChars.Cr, ControlChars.Lf, ","}, StringSplitOptions.RemoveEmptyEntries)
Dim integers As Integer() = New Integer(integerStrings.Length - 1) {}
Dim IntIndx As Integer = -1
'Dim Intvalid As Boolean = False
Dim TestInt As Integer = 0
For n As Integer = 0 To integerStrings.Length - 1
Try
'Intvalid = False
TestInt = Integer.Parse(integerStrings(n))
'Intvalid = True
IntIndx += 1
integers(IntIndx) = Integer.Parse(integerStrings(n))
Catch ex As FormatException
Debug.Print("Item contains invalid characters for an Integer" & integerStrings(n))
Catch ex As OverflowException
Debug.Print("Item too Large for an Integer" & integerStrings(n))
End Try
Next
Return integers
Dim numbers As Integer() = ParseNumberFile("c:\test\infile.csv")
Console.WriteLine("No of Integers Read : " & numbers.Length)
Write file
Dim objFS As New FileStream(strFileName, FileMode.Create, FileAccess.Write)
Dim objSW As New StreamWriter(objFS)
Dim arStrings As String() = New String(arIntegers.Length - 1) {}
For fint = 0 To arIntegers.GetUpperBound(0)
arStrings(fint) = arIntegers(fint)
Next
strintegers = Join(arStrings, "|")
' Write out the record to the file ...
objSW.WriteLine(strintegers)
Console.WriteLine("Record was written to the output file.")
Console.WriteLine("")
objSW.Close()
Console.WriteLine("")
Console.WriteLine("File creation complete. Press Enter to close this window.")
Console.ReadLine()
End Sub
Dim qry As String = ""
Dim adoconnectionString As String = ""
Dim paParams() As Object = Nothing
Dim objRow As DataRow = Nothing
Dim dsData As DataSet
Dim sDescription As String = vbNullString
Using db As New AdoHelper(adoconnectionString)
dsData = db.ExecDataSet(qry, paParams)
If dsData.Tables(0).Rows.Count > 0 Then
For Each objRow In dsData.Tables(0).Rows
If Not objRow("Description") Is System.DBNull.Value Then sDescription = objRow("Description")
Next
End If
End Using
|
|
|
|
|
...and the question would be ....??
Edit your post, enclose the code in PRE tags, removing all the extra blanks lines, and only include the code that pertains to the question.
|
|
|
|
|
That is unreadable without proper PRE tags.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
I've been trying to multi-thread a windows service with no luck...it actually goes slower.
We have a table on another SQL DB server (linked to our SQL Server) that contains the keys (SSN & ID, multi SSN & unique ID for the SSN) that we need to process.
Server A is the one we're linked to and getting data from.
Server B is the one we're adding/updating data to.
We read an SSN/ID on server A, get related data for them from server A and update/add to server B. The update/add on server B is with LINQ via VB.NET (not a fan of that (LINQ that is)).
Have tried at least 3 different ways to thread this, all with negative results and can't find a good example.
Also, even when single threaded, it runs slower the longer it runs (85 hrs, starts at about 7000 recs/hr, and ends at about 1200/hr)
Any ideas or point me in a direction?
Thanks.
modified on Friday, May 20, 2011 2:28 PM
|
|
|
|
|
Multi-threading isn't the magical cure to everything. It works well in a lot of situations, and doesn't at all in others. That is due to either the problem being inherently sequential, or the design or implementation being flawed. From what you told us I can't tell which applies to your case.
Here are some suggestions:
- implement it without multi-threading, run a relevant test case, and observe the behavior. In particular look at the CPU load in Task Manager; if it is less than 100% divided by the number of cores, it probably could benefit from multi-threading; and if it is close to 100%, multi-threading will not help at all.
- make sure it isn't as fast as you would like, then make sure you have optimized everything you could reasonably optimize; choose the proper algorithm; apply proper indexing to the database; etc etc. Also make sure you don't have busy loops, i.e. things such as:
while(!done) }
if (newDataAvailable) }
...process new data
}
}
which would spin (and waste cycles) at maximum speed as long as no data is available.
- once you really understand there are blocking calls (waits) that could be hidden (by processing other data in the mean time), start designing a multi-threading approach, at best by just adding a single thread and making sure it meets your expectations.
- then think again about having maybe some more threads.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Do I understand that your service has one connection string and it is connected to Server B ?
When you are accessing data you get the results from a table that is stored on a linked server.
You issue an update to some table on server B with the results obtain from the linked table.
Is the above correct ?
I'm unclear as to where the problem is ... is this a database issue or a multi-thread problem ?
Suggestion:
Is it possible to have 2 connection strings one for each server and not rely on the "linked data" ?
I'm not sure how you are processing your updates, but maybe you could get all your data from the linked server, copy it to a Temp table, then use an update from that Temp table to the table on server B. This would reduce the number of SQL calls.
sounds like a complex problem, but I don't know where to begin to offer advice.
Post some more info and everyone here will try to help you.
Good luck.
|
|
|
|
|
Hi,
I have installed VS2010; now I have only FW4 as posibility for my projects.
So when I open an older project it will not load.
I have click on add other frameworks but no luck.
Can someone help me
Jan
PS VS2008 was installed also
|
|
|
|
|
I draw your attention to This[^] page.
A snippet...
"Application Compatibility and Deployment
The .NET Framework 4 is highly compatible with applications that are built with earlier .NET Framework versions, except for some changes that were made to improve security, standards compliance, correctness, reliability, and performance.
The .NET Framework 4 does not automatically use its version of the common language runtime to run applications that are built with earlier versions of the .NET Framework. To run older applications with .NET Framework 4, you must compile your application with the target .NET Framework version specified in the properties for your project in Visual Studio, or you can specify the supported runtime with the <supportedRuntime> Element in an application configuration file.
If your application or component does not work after .NET Framework 4 is installed, please submit a bug on the Microsoft Connect Web site. You can test compatibility as described in the .NET Framework 4 Application Compatibility topic and learn about new features by using the Visual Studio 2010 and .NET Framework 4 Walkthroughs. For additional information and known migration issues, visit the .NET Framework Compatibility blog."
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
CCC Link[ ^]
Trolls[ ^]
|
|
|
|
|
I am not sure who upvoted you, DD, but that is not a good answer. The OP is not talking about an app targeting an earlier version of .Net that is not working on .Net 4. The OP is talking about not even being able to create an app targeting an earlier version of .Net.
|
|
|
|
|
Do you have the older frameworks installed? .Net is completely autonomous and does not need previous frameworks to work, so you may have to install them. When you create a new project, there is a little drop down at the top of the window that allows you to select the framework. "More Frameworks" should be an option and it will send you here. The right of the page lists older frameworks you can install. Note that .Net 3 and 3.5 require .Net 2.
Also, if you are using an Express edition, I am not sure if that supports the old frameworks or not.
|
|
|
|
|
Hi, dear all,
I create a project using VB.net in 2005, I need to list a set of file path to a datagridview table. I put horizontal scrollbar as auto, everything is fine.
Now client complains that when the file path is too long, they cannot see the file name, they wish if the file path is too long, he want to see the last text (string end) than the first text(begining of the string) of the file path.
How can I achieve this?
Thanks!
|
|
|
|
|
Well, the first thing I thought of was custom formatting the string on render and just displaying the filename, maybe with an ellipses (...) before the name, like this: "...\SomeFile.txt".
But, then you've got to take into consideration whether the user is going to click on this and be able to select that data to do something with it or edit it in place.
|
|
|
|
|
Dave,
Thanks for reply,
The file path string is just for display purpose.
|
|
|
|
|
You could use the CellFormatting event to alter the way the cell shows the data, or to alter the data that gets displayed.
And you could shorten the file path any way you want, maybe as suggested here[^].
Finally you can still get a ToolTip for the cell in another way if you want, see the CellToolTipTextNeeded event.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Luc,
Thanks for give me the good suggestion.
|
|
|
|
|
Hi,
i searched around the Net and Code Project for some existing parser, but so far unsuccessful.
What I want to do is parse a Visual Basic .FRM (form) file and extract the control names defined within. I also want to determine if there are nested controls within.
If possible, convert the listing and nested information into some format that can be easily worked with by other tools - like XML or some identifiable tree structure.
For example (MyForm.frm):
Begin Control1Lib.Cntrl1 MyCntrl1
Height = 555
Left = 0
...
Begin Control2Lib.Cntrl2 MyNestedCntrl2
Height = 375
...
BeginProperty Font {aldfladlf-lsl-ladsjlfj}
...
EndProperty
End
End
Then the parser could tell me I have two controls (MyCntrl1, MyNestedCntrl2) and SHOW that MyNestedCntrl2 is nested inside MyCntrl1.
Examples:
Level ControlName
1.0 MyCntrl1
1.1 MyNestedCntrl2
2.0 MyCntrl2
2.1 Nested2_1
2.2 Nested2_2
3.0 MyCntrl3
3.1 Nested3_1
3.1.1 Nested3_1_1
3.1.1.1 Nested3_1_1_1
...
XML example:
<MyCntrl1>
<MyNestedCntrl2>
</MyNestedCntrl2>
</MyCntrl1>
<MyCntrl3>
<Nested3_1>
<Nested3_1_1>
<Nested3_1_1_1>
</Nested3_1_1_1>
</Nested3_1_1>
</Nested3_1>
</MyCntrl3>
I am sure this is somewhere out on the Net where I can download, so can you point me to the place to research?
Thank you much!
JJ
|
|
|
|
|
First, not to piss on your parade route, but WHY? VB6 is long since dead and not supported by anyone any more. What tools do you think are going to want to know this stuff when nobody is developing new tools for VB6?
Second, the FRM file is just a text file. There really isn't any parser out there that I can find (probably because VB6 has been outdated for 10 years now) Writing one should be pretty straight forward.
|
|
|
|
|
True that, and that's basically why i want to achieve what I'm asking...
I have some legacy application and there are some 3rd party controls that have long since been retired. I want a method to identify all the controls in my application and determine what needs attention.
My take on this would be to write my own simple parser to:
1. search .FRM for "Begin" <type> <control variable name>
2. for each "Begin", push onto a stack (var name, unique id, level++)
3. for each "End", pop from stack, print info (id++, level--, var name)
(you can see my c++ tendencies)
It seemed quicker to ask the community before setting off and writing.
Cheers.
|
|
|
|
|
The logic seems reasonable. I'd start writing because you'll probably spend just as much effort to find something that does it for you.
|
|
|
|
|
How can I log into a website. Lets take as an example, logging into codeproject.com. I have:
Dim objIE
Set objIE = WScript.CreateObject("InternetExplorer.Application")
objIE.Navigate "http://www.codeproject.com"
objIE.Visible = true
While objIE.Busy = true
Wend
objIE.Document.All("Email").Value = "brinasas@yahoo.com"
objIE.Document.All("Password").Value = "xxxxxx"
objIE.Document.All("button").Click
'Dim Wsh : set Wsh = CreateObject("WScript.Shell")
'Wsh.SendKeys "{ENTER}"
But the above script gives me an error. Any feedback anyone can give me will be
greatly appreciated.
|
|
|
|
|
Why is it noone ever thinks the error message is an important detail to put into a post concerning the non-functioning of a piece of code?
|
|
|
|
|
The error says:
Line: 10
Char: 1
Error: Object required: 'Document.All(...)'
Code: 800A01A8
Source: Microsoft VBScrpt runtime error
Line 10 is this line:
objIE.Document.All("Email").Value = "brinasas@yahoo.com"
Any response you can give me will be greatly appreciated.
|
|
|
|
|
That would be because Document.All("Email") didn't return an object. This means you cannot set the Value property of an object that doesn't exist.
You may want to check to see if that code returned an object before you try and use it.
Dim c
Set c = objIE.Document.All("Email")
If c Is Nothing Then
' A control called "Email" doesn't exist in the page!
' Handle this condition appropriately.
Else
c.Value = "blah@somewhere.net"
End If
|
|
|
|
|
Read This[^], it may help.
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
CCC Link[ ^]
Trolls[ ^]
|
|
|
|