|
This Format method of WMI is a member of a Volume object, therefore, it would format that particular volume.
Why don't you start with the link i gave you and work your way back up the WMI documentation, and you will see all sorts of classes and methods.
There are classes that enumerate the logical disk, volumes, drive types etc. etc.
There are examples scattered all over the place to do different things, so i guess a little bit of googling will eventually get you want you want.
|
|
|
|
|
I have a VBScript that uses WMI to format a drive. I got the code from some site but it is not formatting my pen drvie and giving error while executing the script.
The code is below:
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colVolumes = objWMIService.ExecQuery _
("Select * from Win32_Volume Where Name = 'G:\\'")
For Each objVolume in colVolumes
errResult = objVolume.Format("NTFS")
Next
Here G: is my pen drive's drive name.
Suggest me how to format my pen drive.
Thanks.
Gagan
|
|
|
|
|
Hi all,
I am trying to copy a whole directory that contains files and subfolders. I have done a lot of searching on the web but I cannot find anything. I want to be able to show the progress of the copy in a progress bar. Sorry, I am new to vb.
Thanks
majan11
|
|
|
|
|
Hi,
welcome to CodeProject.
majan11 wrote: I am new to vb.
I hope that is VB.NET, not ancient VB which is unsupported and obsolete since a few years.
In .NET you would need these classes: Form, ProgressBar, DirectoryInfo, Directory, File, and maybe more. I suggest you read up on these; but maybe best is to study a book on VB.NET first, that will give you the fundamentals of the language and .NET programming in general.
|
|
|
|
|
Yes it is VB.NET. I will look into those classes you specified. Thanks
majan11
|
|
|
|
|
I've done something similar, involving copying a large number of files from one single folder into another. I started with a preliminary count of the number of files to be moved, then set the Maximum value of the progress bar to that number. Then, after copying each file, I incremented the progress bar value by one. The code looks like this:
AppMainForm.ProgressBarVisible = False
AppMainForm.ProgressBarMinimum = 1
AppMainForm.ProgressBarMaximum = Directory.GetFiles(ArchivePath).Length
AppMainForm.ProgressBarValue = 1
Dim DestPath As String = ""
For Each F As String In System.IO.Directory.GetFiles(ArchivePath)
If AppMainForm.ProgressBarVisible Then
AppMainForm.ProgressBarIncrement()
Else
AppMainForm.ProgressBarVisible = True
End If
DestPath = WebPath + System.IO.Path.GetFileName(F)
My.Computer.FileSystem.CopyFile(F, DestPath, True)
Next
AppMainForm is the MDI for the app, implemented as an interface; the progress bar is exposed as various properties and methods through the interface. The method ProgressBarIncrement simply adds 1 to the progress bar's value.
You should be able to modify this to allow for a recursive copy as well. At a guess, I would thing a two pass system might work, one to create the folder structure and one to copy the files. It might be visually interesting to implement two progress bars, one showing the copying of the current folder and one marking overall progress.
|
|
|
|
|
i am having trouble writing a program that i have to reuse the same input box and give a average of the numbers does anyone know how to retain each value so i can average them.
thank you for any help!!
|
|
|
|
|
Store each value in a List(of T) where T is an integer. You can then iterate over the list, adding all of the the values together and take the average.Scott Dorman Microsoft® MVP - Visual C# | MCPD
President - Tampa Bay IASA
[ Blog][ Articles][ Forum Guidelines] Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
|
|
|
|
|
you never need all the numbers at once, you could calculate sum and count while taking the input numbers one by one.
|
|
|
|
|
trying to print from a file but nothing prints. here is the code.
Private Sub document_PrintPage(ByVal sender As Object, _<br />
ByVal e As System.Drawing.Printing.PrintPageEventArgs) _<br />
Handles docToPrint.PrintPage<br />
<br />
Dim printFont As New System.Drawing.Font _<br />
("Arial", 12, System.Drawing.FontStyle.Regular)<br />
' Insert code to render the page here.<br />
' This code will be called when the control is drawn.<br />
<br />
' The following code will render a simple<br />
' message on the printed document.<br />
<br />
<br />
If System.IO.File.Exists(SaveFileDialog1.FileName) Then<br />
count = 0<br />
menu2 = File.OpenText(SaveFileDialog1.FileName)<br />
menu2 = System.IO.File.OpenText(SaveFileDialog1.FileName)<br />
Do Until menu2.Peek = -1<br />
menuitem(count) = menu2.ReadLine<br />
'e.Graphics.DrawString(menuitem(count), printFont, _<br />
'System.Drawing.Brushes.Black, 10, 10)<br />
'e.Graphics.DrawString(writeline(count), printFont, _<br />
'System.Drawing.Brushes.Black, 10, 10)<br />
count = count + 1<br />
Loop<br />
For counter = 0 To count<br />
e.Graphics.DrawString(menuitem(count), printFont, _<br />
System.Drawing.Brushes.Black, 10, 10)<br />
e.Graphics.DrawString(writeline(count), printFont, _<br />
System.Drawing.Brushes.Black, 10, 10)<br />
Next counter<br />
menu2.Close()<br />
<br />
<br />
End If<br />
<br />
<br />
<br />
' Draw the content.<br />
<br />
End Sub
|
|
|
|
|
I just want to start by saying that i have been out of the programming game for a while and i just started to do a little work on a old project of mine. All i want to do is be make a listbox recognize when more than one key is pressed. To be exact, i want ctrl+A to do a select all in the listbox. I figure that .NET has something that i do not know about that is builtin to make this task easy. Thank you for a help that is provided.
|
|
|
|
|
there are two easy ways to get that:
1.
provide a MainMenu and some Menu Item that allows the user to do whatever it is you want the shortcut to do too. Then set the shortcut for that Menu Item. Done.
2.
Set Form.KeyPreview true, provide a Form.KeyDown handler that checks for KeyEventArgs.Control And KeyEventArgs.KeyCode=Keys.A
BTW: you can always get the instantaneous state of the modifier keys from Control.ModifierKeys
|
|
|
|
|
instead of using spaced to space out data how would using tabs spacing instead using code. If would to replace spacing with tab stops instead.
writeline(2) = filename(0) + " " + "Qty" + " " + FormatCurrency(filename1(0)) + " " + "Total Cost"
|
|
|
|
|
when the displaying "device" is tab-capable, it typically interprets a tab as "move to the next position/column number that is a multiple of N" where N is often 8 or 4. So the net effect of a tab character depends on what is present to the left of it, making it not so easy to generate correctly.
if all you need is getting some columnar output, maybe string.PadLeft() and string.PadRight() could fit the bill.
|
|
|
|
|
<pre>writeline(2) = filename(0) + vbTab + "Qty" + vbTab + FormatCurrency(filename1(0)) + vbTab + "Total Cost"</pre>
David Anton
Convert between VB, C#, C++, & Java
www.tangiblesoftwaresolutions.com
|
|
|
|
|
Hi All,
I want to set the width of column of excel while generating excel through code(on button click) in VB application.Any one knows how to do it...!!!!!!
|
|
|
|
|
Columns("C:C").Select
Selection.ColumnWidth = 17.71
Obviously where I have set the specified columns as "C:C" you could set as (Col1:Col2), and where I have put in a set column width you could have a variable.
I hope this helps.------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
|
|
|
|
|
Hi all..i have a form having tabs in VB application.I want to add a text box to one tab only..when i drag and drop the text box-it appears in both the tab.means text box is overriding the form..some one can help me out..how to fix textbox to particular tab..!!
|
|
|
|
|
Place the Tab control on the form
Click the tab for the tabpanel you want to have the control on.
Drag the control onto the panel.
If it appears that the textbox is on both, it is because it is actually on the parent form and is sitting in front of the tab control.
|
|
|
|
|
hi
i m generating a output report in MS word document.
i middle of report few values are based on user input
if user inputs quantity =2 then i want to display two paragraphs
simialary if quantity=3 then i want to display 3 paragraphs
can one help me ...
|
|
|
|
|
MsWrdFile = New Microsoft.Office.Interop.Word.Application
MsWrdFile = CreateObject("Word.Application")
MsWrdFile.Documents.Add()
MsDcmt = MsWrdFile.ActiveDocument
Dim Rg1 As Microsoft.Office.Interop.Word.Range = MsWrdFile.ActiveDocument.Range(Start:=0, End:=0)
MsWrdFile.ActiveDocument.Tables.Add(Rg1, 3, 4)
MsWrdFile.ActiveDocument.Tables(1).Style = "Table Grid 8"
For I As Integer = 0 To 2
Dim oPara_i As Microsoft.Office.Interop.Word.Paragraph
oPara_i = MsWrdFile.ActiveDocument.Content.Paragraphs.Add
If I = 0 Then
oPara_i.Range.Text = "Heading 0"
ElseIf I = 1 Then
oPara_i.Range.Text = "Heading 1"
ElseIf I = 2 Then
oPara_i.Range.Text = "Heading 2"
End If
oPara_i.Range.Font.Bold = True
oPara_i.Format.SpaceAfter = 24 '24 pt spacing after paragraph.
oPara_i.Range.InsertParagraphAfter()
Next
MsWrdFile.Visible = True
MsWrdFile.Quit()
|
|
|
|
|
Hi,
I need to store a string that represent an XML file in a database. In the database, the field is of type ntext. The XML parser will take that field and extract all he needs. The XML parser expect an UTF-8 encoding. Since in VB.Net a string type is UTF-16, I can't create my XML string and store that string in the db because I will have an UTF-16 encoding instead of UTF-8 encoding. What I understand is that in VB I can create a byte array and convert my string to UTF-8 and store that conversion in the byte array. My question: how can I write that array to the field in the database that he is of type ntext?
Thanksmodified on Tuesday, March 9, 2010 8:12 PM
|
|
|
|
|
Change the field type to text. nText is for Unicode, or National Text as defined by SQL-92.
|
|
|
|
|
Unfortunately, I have no control on the database.
|
|
|
|
|
OK. let's see what your code looks like that is storing the XML and retrieving it.
|
|
|
|