|
Hi everyone. Just wondering if you could help me with this (I have never used VB before). Anyway, if I have a combo box, how do I add items to it through code?
I understand you have to use the AddItem, but dont know the syntax. Please help if you can.
|
|
|
|
|
ComboBox1.AddItem "Item"
simple, eh!
God, I pity me! - Phoncible P. Bone
If I end up Windows ME someone is going to be hurting. - One of the answers to a question for What OS are you
|
|
|
|
|
Hi,
I'm want to print the text file from my application. I use the code below and i use dot-matrix printer to print.
However, i find that the printing process is very slow because the printer will print twice per line.
What other method that can be used other than the method below? What other object can be used to print instead of ev.Graphics.DrawString? Or what other setting can used to make the printing faster/print once per row.
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim prtdoc As PrintDocument = New PrintDocument()
Dim strDefaultPrinter As String = prtdoc.PrinterSettings.PrinterName
Dim strPrinter As String
For Each strPrinter In PrinterSettings.InstalledPrinters
ComboBox1.Items.Add(strPrinter)
If (strPrinter = strDefaultPrinter) Then
ComboBox1.SelectedIndex = ComboBox1.Items.IndexOf(strPrinter)
End If
Next
End Sub
Private Sub pd_PrintPage(ByVal sender As Object, ByVal ev As PrintPageEventArgs)
Dim linesPerPage As Single = 0
Dim yPos As Single = 0
Dim count As Integer = 0
Dim leftMargin As Single = 0
Dim topMargin As Single = 0
Dim line As String = Nothing
' Calculate the number of lines per page.
linesPerPage = ev.MarginBounds.Height / printFont.GetHeight(ev.Graphics)
' Iterate over the file, printing each line.
While count < linesPerPage
line = streamToPrint.ReadLine()
If line Is Nothing Then
Exit While
End If
yPos = topMargin + count * printFont.GetHeight(ev.Graphics)
ev.Graphics.DrawString(line, printFont, Brushes.Black, leftMargin, _
yPos, New StringFormat())
count += 1
End While
'If more lines exist, print another page.
If Not (line Is Nothing) Then
ev.HasMorePages = True
Else
ev.HasMorePages = False
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
streamToPrint = New StreamReader("D:\abc.txt")
Try
printFont = New Font("Verdana", 10)
Dim pd As New PrintDocument()
pd.PrinterSettings.PrinterName = ComboBox1.SelectedItem
If (pd.PrinterSettings.IsValid) Then
AddHandler pd.PrintPage, AddressOf pd_PrintPage
' Print the document.
pd.Print()
Else
MessageBox.Show("Invalid Printer")
End If
Finally
streamToPrint.Close()
End Try
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
|
|
|
|
|
I'm writeing a small app to automate common taskes in a console based application.I need to send key strokes from my application to the other application, while it is running.I have tried to use System.IO.Process.StandardInput.Write("c") etc but it doesn't work for me. Any thoughts on how to go about this? More generaly is there an easy way (or hard way for that mater) to send an arbitrary windows message to another application?
Thanks
---Quatl
|
|
|
|
|
You could try using SendKeys(), which in theory might work, it is placing keys into the keyboard buffer after all, so another app. that has the foucs might well pick them up.
|
|
|
|
|
Does anyone know how to read/ get the body of message which is in RTF format.. from outlook mailitem?
I could read the message bodies which have either html or plain text format and store it in msg ( msg = String)... but whenever I tried to get the body with RTF format.. I lost all the text format like bold, table, etc..
I tried to used mailItem.HTMLBody and it gave me empty string sicne it is only work for HTML body...
So I found another article [URL=http://support.microsoft.com/default.aspx?scid=kb;en-us;172038]on Microsoft about reading and writing the RTF body message dll [/URL].
I tried to use it but it doesn't work either..
maybe i'm using the wrong way..
anybody used it before???
|
|
|
|
|
I am using the MSChart Control from VB6 using COM Interop. I am creating a 3d line chart. I need to make a bitmap or GIF or whatever of this chart. Can anyone tell me how to do this? Maybe doing something like a Print Screen or something? Thank for any help!
|
|
|
|
|
Hi, I was wondering if there is "report viewer" sample somewhere out there... I need an MS-Access report viewer that does NOT need MS-Access installed on the machine. I understand that in earlier versions of Access, it was possible using the Access Developer's Kit (ADT), but I don't really know how to use it, or any other better and more modern kits - if any exist.
The scenario is this: I have a machine, holding an MS-Access database, that has a few reports in store. The user is using a DIFFERENT computer, and wants to remotely view the reports inside the MS-Access database, but the user doesn't have Access installed.
Thanks..
/=/=/=/=
Deus
/=/=/=/=
|
|
|
|
|
Try the "Snapshot Viewer" free from MS...
|
|
|
|
|
Hello
I am building an application that is going to need the ability to schedule
certain tasks. Using the NetScheduleJobAdd API works wonders for Windows
NT/2K/XP and 2003 but it is not supported by Windows 95/98/ME. Any
alternatives?
Thanks!
|
|
|
|
|
According to this page, http://www.altecdata.com/task_scheduler.htm "However, Windows 95, Windows 98 and Windows NT were released before the Windows Task Scheduler was available and it is therefore added when Internet Explorer 4 (or later) is installed."
So, first question I'd ask is ... do you have IE 4 (or later installed).. I've done some web searching, and it seems if the is the case it should be available ...
hth
Garth
|
|
|
|
|
|
Hi,
I need some help with a question.
First I am using VBScript for a client side spellchecker. The code below works but does not keep the rich text formatting that I need.
Sub RichTextSpellChecker(ItemToCheck)
Dim WordObject
Dim WordDocumentObject
Dim strReturnValue
Dim strValueToCheck
strValueToCheck = "" & document.getElementById(ItemToCheck).innerTEXT
IF NOT (strValueToCheck = "") THEN
'let the user know that the spelling is being checked.
window.status = "Spell Check is processing, please wait this may take a few seconds."
'Create a new instance of word Application
Set WordObject = CreateObject("word.Application")
'set window parameters
WordObject.WindowState = 2
WordObject.Visible = False
'Create a new instance of Document and add the text to the document
Set WordDocumentObject = WordObject.Documents.Add( , , 1, True)
WordDocumentObject.Content = strValueToCheck
WordDocumentObject.CheckSpelling
'Return spell check completed text data
strReturnValue = WordDocumentObject.Content
'give the corrected spelling to the textbox that was checked
'MsgBox(strReturnValue)
document.getElementById(ItemToCheck).innerTEXT = strReturnValue
' House Cleaning
'Close Word Document
WordDocumentObject.Close False
'Set Document To nothing
Set WordDocumentObject = Nothing
'Quit Word
WordObject.Application.Quit True
'Set word object To nothing
Set WordObject= Nothing
'let the user know that the spell check has completed. just incase it takes a few seconds to reload the page.
window.status = "Spell check is complete"
END IF
End Sub
As you can see I am using innerTEXT because if I try to use innerHTML the spellchecker will come back and tell me that
HI is spelled incorrectly. Is there a way to keep the text formatting while using the spellchecker?
Thanks
William O'Malley
__________________
|
|
|
|
|
Greetings,
I would like to know,If I can change my form shape from square
to a rounded corners one.
And how do I create it?
Thank you very much Yamarain
|
|
|
|
|
Here are a few links that should get you started:
http://www.freevbcode.com/ShowCode.Asp?ID=3723[^]
http://www.windx.com/codemag/Article/11518/0/page/2[^]
Sorry they are not CP resources.. I looked and looked and looked.....
Paul Watson wrote:
"At the end of the day it is what you produce that counts, not how many doctorates you have on the wall."
George Carlin wrote:
"Don't sweat the petty things, and don't pet the sweaty things."
Jörgen Sigvardsson wrote:
If the physicists find a universal theory describing the laws of universe, I'm sure the a**hole constant will be an integral part of that theory.
|
|
|
|
|
|
Hey guys!
Could anyone tell me how to do a HTTP POST with the HTTPWebRequest class?
I've looked it up in MSDN and tried several times, but it just won't work...
It would help if I could get a little piece of code... for example logging into yahoo mail or whatever
Thanks a lot!
-Timo
|
|
|
|
|
I have a program that acts just like the right button off the mouse on top of the desktop, it only appears a menu...
here's the code:
Private Sub Form_Load()
Me.Hide
Me.PopupMenu ExecMenu
Unload Me
End Sub
Private Sub mnuDebug_Click()
MsgBox "debug"
Unload Me
End Sub
Private Sub mnuRun_Click()
MsgBox "run"
Unload Me
End Sub
-----------------------------------------------------
I want the program to exit when the ESC key is pressed or when the program lost the focus, just like a normal menu...
The line: Unload Me in Form_Load works well in the IDE but when I build the exe it stop working...
How can I exit my program the way I want?
|
|
|
|
|
Hello,
A quite simple question :
I have add an error handler to my VB project. Everything's perfect. But when I catch a run-time error, how to get the line number where the error occurs ?
I'm using VB6 and I haven't find such property on the err object.
Thanks in advance !
|
|
|
|
|
Broker2003 wrote:
I'm using VB6 and I haven't find such property on the err object.
That's because the property doesn't exist. You can't determine the line number while in the executable because that information is not saved written to the executable. The closest your going to get is the name of the class or module that generated the error.
RageInTheMachine9532
|
|
|
|
|
VB V5 used to have an undocumented function called Erl that would return it as long as you preceded each line of code with a number. Ech!
To do this now days all i do is set a variable called lineNo in each function I use and incriment that as my code moves on. Then in my error handler I can simply refer to that var as the last point where I was processing. I don;t obviously do this for each and every line of code I have, but rather I number logical groups of code together.
Paul Watson wrote:
"At the end of the day it is what you produce that counts, not how many doctorates you have on the wall."
George Carlin wrote:
"Don't sweat the petty things, and don't pet the sweaty things."
Jörgen Sigvardsson wrote:
If the physicists find a universal theory describing the laws of universe, I'm sure the a**hole constant will be an integral part of that theory.
|
|
|
|
|
Use the Erl function. But in order to get it work, you need to number your lines of code. A very useful tool is MZTools, which can do that and a lot of other very interesting stuff. (http://www.mztools.com/)
|
|
|
|
|
Does anybody know how to bounce data between two unrelated classes? I know you can call subroutines in the derived class from the base class, but im not sure how to go the other way. To be more specific, I'm trying to change a property on a control in one form from another. Please help
Scientist have pondered for thousands of years, "What came first? The CodeChicken or the egg?".
|
|
|
|
|
Just thought I'd let everybody know that I figured this out and this is how I did it. For instance, if form1 spawns a new class called class1, you dimension a reference to the form inside the class with this code:
public formlink as form1 = form1.activeform
After you've done this, you can call anything from form1 using formlink. For instance to add to a listbox on form1 from class1 you would use this code:
formlink.listbox1.items.add("hello world")
I hope this helps anyone else that is trying to pass data between forms. I know it was easier in vb6, but now that forms are classes, it makes it much more confusing. Thanx for reading
Scientist have pondered for thousands of years, "What came first? The CodeChicken or the egg?".
|
|
|
|
|
if you want to pass data between forms , you can add owned forms, eg:
in Form1:
Dim frm As New Form2<br />
Me.AddOwnedForm(frm)<br />
frm.Show()
in Form2:
Dim frmMain As Form1 = Me.Owner<br />
frmMain.TextBox1.Text = "something from Form2, passed to Form1!"
|
|
|
|