|
PadLeft is the winner.
Just what I was looking to do.
Thanks,
david
|
|
|
|
|
Composite formatting using indexed placeholders "{0}" allows for alignment but standard formatting with the ToString method does not.
Example of alignment in a fixed width field
Console.WriteLine("{0, -4}", 99);
Console.WriteLine("{0, 4}", 99);
Debug.Print has an overload for composite formatting so you can do the same trick.
Alan.
|
|
|
|
|
String.Format will do what you want for creating strings.
|
|
|
|
|
Don't think there is one! You'd have to create a string and add leading spaces according to its initial length.
|
|
|
|
|
Good day, i have an application which can upload and preview image files, e-presentations, word duments, excel files and pdf files. On my program i used Web Browser Control and I'm planning to change the component or upgrade the software. Aside from Web Browser Control, what else can I use to preview those file types? Any suggestions and comments will be appreciated.
darylljoecanan™
|
|
|
|
|
Don't post the same question in multiple places. You already posted it in QA.
Once is enough and the regulars around here will see it.
|
|
|
|
|
Dear, The code project admin..
when i make a vb project into an exe file, i have a problem, appear it says file not found : cs2.exe
what should i do to solve the problem?
thank you for the solution...
|
|
|
|
|
Find the file! Seriously, what is the build system trying to do at the point that it cannot find this file? If this is one of the Visual Studio files then you may need to do a re-install.
|
|
|
|
|
so, the error occur because there are corrupted file?
|
|
|
|
|
rizaky2011 wrote: the error occur because there are corrupted file?
No, the error has occurred because a file cannot be found. Check the build logs to see where the file is supposed to be stored and check those directories. If the file is definitely missing then a re-install of VS should fix it.
|
|
|
|
|
|
Solution concept: I am doing a recursive search through directories to find Excel files and then silently open them to find all the macro code, copy the code and then store it.
Problem: When I open some Excel documents, some of these documents have external data connections (ODBC and XML Sharepoint Lists). When the refresh occurs prompts for data source credentials pop-up. Excel tries to refresh the data on this line:
ExcelWb = ExcelApp.Workbooks.Open(FileName, , True, )
before I can get the chance to iterate through the connection collection and disable refresh.
My code snippet for opening the Excel workbook is:
Dim ExcelWb As Microsoft.Office.Interop.Excel.Workbook
Dim ExcelApp As Microsoft.Office.Interop.Excel.Application
ExcelApp = New Microsoft.Office.Interop.Excel.Application
ExcelApp.DisplayAlerts = False
ExcelApp.EnableEvents = False
ExcelWb = ExcelApp.Workbooks.Open(FileName, , True, )
which is fine and everything else in the solution works.
The .ConnectionsDisabled property of the .Workbook object is a read only property, and as I say the refresh occurs in the .Open method before going to the next line of code, not giving me the opportunity to disable conneciton objects in the collection.
I am using the Interop namespace rather than the tools namespace, but I don't think that makes much of a difference regarding object methods and properties.
Is there a better way to manage this to disable the connection refresh?
|
|
|
|
|
Found a solution. Not necessarily the right way, but it works.
adding these two lines before opening the workbook seems to fix the issue.
ExcelApp.AutomationSecurity = 3
ExcelApp.AskToUpdateLinks = True
The first line completely disables all macros, by default security is set to Low.
Second Line, the default is to autmatically update links. By forcing a prompt even when the UI is supressed, the automation component continues and no noisy dialog boxes appear.
|
|
|
|
|
Hi,
I have a DataSet with two tables that have a common field.
Table 1 contains order header data and table 2 order row data. Both tables contain data of multiple orders.
I want to handle each order separately, and my current method is a loop inside a loop and a "manual" check. For example something like this:
For Each rwH as DataRow in ds.Tables("H").Rows
For Each rwR as DataRow in ds.Tables("R").Rows
If rwH.Item("KeyField").ToString = rwR.Item("KeyField").ToString Then
End If
Next
Next
The question is, is there a way to avoid having to loop through the rows, and use this sort of crudish comparison ?
I was thinking maybe creating a foreign key constraint. However, although I know how to create the constraint, I do not know how to use it to my advantage with any loop (assuming it is possible at all) ?
Or can someone suggest an alternative (better) method ?
All input is appreciated.
Cheers,
Johan
My advice is free, and you may get what you paid for.
|
|
|
|
|
Why not have a query that joins the two tables and groups by KeyField or something of that nature?
""Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Please see my answer to Dave's post.
My advice is free, and you may get what you paid for.
|
|
|
|
|
Soooo, you're going to look at the same set of records (inner loop) over and over again, until you match them up with the records in the outer loop?? How many records in the outer loop again?? That seems AWFULLY inefficient.
Why not just create a SQL query that matches everything up for you?
|
|
|
|
|
It is awfully inefficient, hence the question.
In this scenario I need to create orders into an ERP system via a proprietary driver.
That means that I need to declare a new "order" object, and fill in all its properties. Some header data (customer name, and address, and such), and an unknown number of rows (product number, quantity, price, etc.). In addition I need to translate that same information into an email message.
So if I combine both header and row data into a single query, I would have to populate the header data of the order object over and over, for each row, or build in some kind of is-it-already-populated method. Somehow that does not seem very efficient (or elegant) either (I may very well be wrong of course).
For clarity, the header table will generally only contain between 1 and 10 records, the rows table however can contain anywhere between 1 and 150 records per header record. Eliminating the nested loop is therefore my main concern here.
My advice is free, and you may get what you paid for.
modified 6-Jun-12 3:03am.
|
|
|
|
|
You can at least eliminate the nested loop with a SELECT:
dim drRows() as DataRow = ds.Tables("R").Select("KeyField = '" & rwH.Item("KeyField").ToString & "'")
If drRows.Length > 0 Then
End If
|
|
|
|
|
Thanks, I didn't know about this one. It seems to be exactly what I need.
My advice is free, and you may get what you paid for.
|
|
|
|
|
Several weeks ago you folks helped me with a problem and I have another problem I hope you can help with.
I created, with your help, a small program that spun three will like a slot machine and randomly placed 2 values and a sign, in picture boxes to create a very basic math problem to be solved. I did this for my 6 year old granddaughter and she LOVES IT!.
In fact she took the program to school and the teacher loved it as well. After a little work I jazzed up the program with some flashy graphics and sound. She wants to add the program to her teaching library. Before I give her a copy I wanted to add some animation to the reels by adding short AVI files. Creating the files was no problem, getting them to play was.
Can anyone steer me to some actually complete code that will play a AVI file in a picture box, that IS DOCUMENTED with remark statements so I can see what they are doing in the code.
On the same note is there a format the AVI file must be in to play? I learned that to play a wave file using the Autoplaymode function the wave file had to be in PCM format. Is there some such requirement for AVI files?
Thanks for your help
|
|
|
|
|
How do I make an os in vb2010 help tanks
|
|
|
|
|
You probably don't. However, there are plenty of articles around on writing your own OS, take a look here[^], or try Google.
|
|
|
|
|
You don't.
You're welcome.
Bastard Programmer from Hell
|
|
|
|
|
If you're going to call yourself "code master", you better know what you're doing and why this is a bad idea.
Can it be done? Yeah, but with extreme difficulty. Check out Cosmos[^], a (mostly) C# written OS.
|
|
|
|