|
Tables, relational.
One table with people, one with races, one that combines a race, a person, and a time. Easy to query.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
so, is this a hashtable? an array? what is used in VB to set up a table, relational?
|
|
|
|
|
DJHJr wrote: table, relational
Fairly certain his is talking about a relational database.
|
|
|
|
|
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.
|
|
|
|
|
thanks...I think I am being thick...I'll read up on database structures. Will keep you posted with my progress
|
|
|
|
|
Okay. I've done some more work, and created some tables and have my logic, Tables, and Keys planned. My consternation now is how to open connections to SQL databases. I cant seem to find a good resource on how to create and then read/write to the database. Any ideas??
|
|
|
|
|
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.
|
|
|
|
|
Assignment
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.
Example
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.
Module Module1
Dim miles As Decimal = 0
Dim kilometers As Decimal = 0
Dim answer As String
Sub Main()
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.ReadLine()
Call convertMilesToKilometers()
Console.WriteLine("The converted value is: " & kilometers)
ElseIf answer = "kilometers" Then
Console.WriteLine("What is the number of kilometers?")
Console.ReadLine()
Call convertKilometersToMiles()
Console.WriteLine("The converted value is: " & miles)
End If
Console.ReadLine()
End Sub
Function convertMilesToKilometers() As Decimal
kilometers = miles / 0.62137
Return kilometers
End Function
Function convertKilometersToMiles() As Decimal
miles = kilometers * 0.62137
Return miles
End Function
End Module
|
|
|
|
|
What does "I can't get past putting in the number of units to use" mean? You are ignoring any user input except for the,
answer = Console.ReadLine() line. You would have to do something just like that to get the number of miles or kilometers that the user wants to convert....
|
|
|
|
|
Oh, my goodness! I fixed the problem, and now everything works! Thank you!
|
|
|
|
|
|
Not entirely sure what Language you are using here but it looks very much like VB. Therefore assuming that it is VB.
On the surface your code looks correct. If I had to rewrite the code it would look something like this:
Module Module1
Dim distance As Decimal = 0
Dim answer As String = nothing
Sub Main()
Console.WriteLine("Do you want to convert miles or kilometers? (M or K)")
answer = Console.ReadLine()
Console.WriteLine("What is the distance?")
distance = Console.ReadLine()
If answer = "M" Then
Console.WriteLine("The converted value is: " convertToKM(distance))
Else
Console.WriteLine("The converted value is: " & converToML(distance))
End If
Console.ReadLine()
End Sub
Function convertToKM(distance) As Decimal
Dim km as Decimal = 0
km = distance / 0.62137
Return km
End Function
Function convertToML(distance) As Decimal
Dim ml as Decimal = 0
ml = distance * 0.62137
Return ml
End Function
End Module
|
|
|
|
|
Hello,
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.
|
|
|
|
|
Member 10568908 wrote: If you could explain to me what happens exactly I would be very grateful. VB6 is not built for multithreading; the language has been replaced by VB.NET some time ago.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Eddy Vluggen wrote: VB6 is not built for multithreading
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 ..
|
|
|
|
|
Member 10568908 wrote: But it's an event-driven language as I know. It's also still a dead language, and having event's does not make it multithreaded.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
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.
Private Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)
Private Sub Command1_Click()
Debug.Print "Begin Command1"
Sleep 5000
Debug.Print "End Command1"
End Sub
Private Sub Command2_Click()
Debug.Print "Command2"
End Sub
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".
|
|
|
|
|
Hello Nicholas,
I would like to thank you so much for your help and your explanation.
I've tried your code and it explains clearly what the DoEvents instruction does. Actually I wasn't understanding how it works, so your code really helped me out.
Additionally, I've modified it to better understanding, and I think the execution of the code below shows that the events are queued as you've said.
Example: A VB6 application with 2 Command Buttons.
Private Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)
Private Sub Command1_Click()
Debug.Print "Begin Command1"
Do
c = c + 1
Sleep 500
DoEvents
Loop Until c = 10
Debug.Print "End Command1"
End Sub
Private Sub Command2_Click()
Debug.Print "Begin Command2"
Do
c = c + 1
Sleep 500
DoEvents
Loop Until c = 10
Debug.Print "End Command2"
End Sub
When you click in one Command, the program waits for 5 seconds before the "End Command" message appears. When you click on the first then the second, what happens is that :
Begin Command1
Begin Command2
End Command2
End Command1
The whole execution takes 10 seconds. Which means that when raising the command2 event, the execution of command1 code has stopped and waited until the command2 code has finished to be resumed.
This confirms also that it's not multi-threaded as Eddy Vluggen has said.
Thank you all for your help and interaction.
|
|
|
|
|
How do I code this to round my results to 2 decimal places?
Module Module1
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
Sub Main()
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()
Call computeTotal()
Call computeTax()
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 & " .")
Console.ReadLine()
End Sub
Function computeTotal() As Decimal
totalSales = itemQuantity * itemPrice
Return totalSales
End Function
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
End If
taxAmount = totalSales * taxRate
Return taxAmount
End Function
End Module
|
|
|
|
|
Use string.Format to format your values, rather than concatenation which prints all the digits.
|
|
|
|
|
hello all,
brand new to VB. just going through some online tutorials. i seem to encounter an error when using the stack and queue classes. when i enter my code
Private mystack As New Stack
or
Private q As New queue
I get an error 'Type expected'.
I can clear the error by entering
Private mystack As New Collections.Stack
or
Private q As New Collections.queue
Any ideas????
|
|
|
|
|
"queue" isn't the name of a type, but "Queue" is. The type is located in the System.Collections namespace, meaning that it cannot be found unless you "Import" it, or prefix the type with the namespace-name (like System.Collections.Queue).
Add the line "Imports System.Collections" at the top of the file, and all should be well.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Worked like a charm...Thanks
|
|
|
|