For those new to message boards please try to follow a few simple rules when posting your question.
Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
Keep the subject line brief, but descriptive. eg "File Serialization problem"
Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode "<" (and other HTML) characters when pasting" checkbox before pasting anything inside the PRE block, and make sure "Use HTML in this post" check box is checked.
Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
Please do not post links to your question into an unrelated forum such as the lounge. It will be deleted. Likewise, do not post the same question in more than one forum.
Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
No advertising or soliciting.
We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
Hi all. First of all I know that there are a lot of questions like mine, but I just can't solve it.
Secondly, this app have to export XML format from spritesheet to a file.
What I did is just create a simple button, added Macro and pasted this code into:
When I have a basic table with data and a button, which when I press it, I get to the Save As screen. I save it as "out.xml" in my Desktop, but I when press OK, i got and error saying : " Run-time error '9': Subscript out of range ' ", and this
General question. I am new to Visual Basic, but have done my share of programming; albeit years ago. I understand the logic of programming, but my question is more about "best practices"
I'd like to create a program that stores a person's information (Name, contact #, email etc). For each person I'd like to have an array of times for various bike races. Optimally I'd have the ability to store split times as well. Now, different people may have a different number of races.
My question: What is best practice for the type of variables to create for such a project. Array list? Structures? I'm sure there are many ways to index the data with the person, but I'd like to do it in the best, most efficient manner.
I guess my question is more rudimentary. Trying to get my brain around the "best practice" for an indexed array from a VB programming perspective. I have 12 people who could have anywhere from 1 to 20 races. Each race has 4 "split" times. I want to be able to analyze the racers and various stats based on times and courses run. I can handle the "programming logic" I'm struggling with the Programming part of the data organization.
Okay.... and nothing you have said changes that the "best practice" based on the information that you have provided to us at this time is to use a database. If for some reason that you cannot or will not use a database to store and manipulate your data, then I suppose that the next best thing for you to do would be to use a List.
I wrote a small utility app for printing invoices from a DOS Accounting system in PDF format.
I probably made the mistake of placing the Adobe PDF object in a dialog window that I created. I call the dialog window, run a Sub new and program the PDF object to load the PDF which works great except for the action below.
But it always tries to load the PDF in the Adobe Viewer first, and says "Cannot use Adobe Reader to view PDF in your web browser, Reader will now exit. Please exit your browser and try again." So I click OK or something and the Adobe Reader window closes and my dialog appears with the PDF loaded, all formatted and everything.
I'm just trying to get rid of the error message. Any insight or suggestions are appreciated.
It’s often necessary to convert between units. In this exercise, you will create two functions for converting between units of distance. The first function will be called ConvertMilesToKilometers(), which will accept one parameter for the number of miles. It will return the equivalent number of kilometers. The second function will be called ConvertKilometersToMiles() and will accept kilometers as its parameter; this will return the equivalent number of miles.
The main method will ask the user if he or she wants to convert miles to kilometers or kilometers to miles. It will then ask for the number of miles or kilometers. It will call the appropriate method and display the converted value.
To convert miles to kilometers, divide miles by 0.62137. To convert kilometers to miles, multiply kilometers by 0.62137.
Do you want to convert to Miles or Kilometers? (M or K): K
Enter number of Kilometers: 3.5
3.5 kilometers equals 2.174795 miles.
This is what I have so far, but I can't get past putting in the number of units to use. I feel like I'm never going to get a hang of this coding stuff.
Dim miles As Decimal = 0
Dim kilometers As Decimal = 0
Dim answer As String
Console.WriteLine("Do you want to convert miles or kilometers?")
answer = Console.ReadLine()
If answer = "miles" Then
Console.WriteLine("What is the number of miles?")
Console.WriteLine("The converted value is: " & kilometers)
ElseIf answer = "kilometers" Then
Console.WriteLine("What is the number of kilometers?")
Console.WriteLine("The converted value is: " & miles)
Function convertMilesToKilometers() As Decimal
kilometers = miles / 0.62137
Function convertKilometersToMiles() As Decimal
miles = kilometers * 0.62137
I am developing an application with VB6 that need to use serial communication (MSComm control). Each data received from the input must be processed in the OnComm procedure. I have problem handling this OnComm events.
My question is what happens when my program is working inside the OnComm() sub, and another OnComm event rises (receiving new data on the port while the processing of the first data hasn't finished yet) ??
Will my program not begin processing the second event until he finishes with the first, or it will handle them simultaneously, or it will keep the second data waiting in the input buffer .. ??
If you could explain to me what happens exactly I would be very grateful.
But it's an event-driven language as I know. But I still didn't get how events are handled in-there.
When there is short piece of code in an event procedure, everything goes ok. But when there is some "time consuming" code and the event can be raised frequently, here I can no longer understand what happening inside my program ..
I guess the events are going to be queued. At least a lot of events work like that. That means: As soon as you finish the work in your events (or you make a call to DoEvents and please... don't do that if you can avoid it...) the next event which should have been triggered while you were processing something should get processed.
At least that's how the Windows Message queue should work. But you have to test it to be sure it really works that way.
Example: A VB6 application with 2 Command Buttons.
PrivateDeclareSub Sleep Lib"kernel32.dll" (ByVal dwMilliseconds AsLong)
Debug.Print "Begin Command1"
Sleep 5000'DoEvents 'Comment out to see what DoEvents does
Debug.Print "End Command1"EndSubPrivateSub Command2_Click()
If you execute the program and click on Command1 first and then on Command2 you should see that the "End Command1" messages executes before (or after in case of a call to DoEvents) the message "Command2". And that the Event of Command2_Click has been queued while the application was busy processing Command1. You can even Click on Command2 e.g. 3 times and the event will be executed 3 times after the Sleep from Command1 is finished.
But there are cases where this does not apply. An example is the Timer (at least the control you can drag on the form).
Important is that the events are sent through the "Windows message queue".
How do I code this to round my results to 2 decimal places?
Dim itemQuantity As Integer = 0
Dim itemPrice As Decimal = 0
Dim totalSales As Decimal = 0
Dim stateName As String
Dim taxRate As Decimal = 0
Dim taxAmount As Decimal = 0
Dim customerName As String
Console.WriteLine("Please enter your name.")
customerName = Console.ReadLine()
Console.WriteLine("Please enter your state: NJ, FL, or NY")
stateName = Console.ReadLine()
Console.WriteLine("Please enter the number of items purchased.")
itemQuantity = Console.ReadLine()
Console.WriteLine("Please enter the price of the item.")
itemPrice = Console.ReadLine()
Console.WriteLine("The total sales for " & customerName & " are " & totalSales & " .")
Console.WriteLine("The tax amount is " & taxAmount & " based on a tax rate of " & taxRate & " .")
Console.WriteLine("The total with tax is " & totalSales + taxAmount & " .")
Function computeTotal() As Decimal
totalSales = itemQuantity * itemPrice
Function computeTax() As Decimal
If stateName = "NJ" Then
taxRate = 0.07
ElseIf stateName = "FL" Then
taxRate = 0.06
ElseIf stateName = "NY" Then
taxRate = 0.04
taxAmount = totalSales * taxRate
Last Visit: 31-Dec-99 18:00 Last Update: 23-Apr-14 7:13