Jump to content
Xtreme .Net Talk

PlausiblyDamp

Administrators
  • Posts

    7016
  • Joined

  • Last visited

Everything posted by PlausiblyDamp

  1. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vblr7/html/vaconvbcompileroptions.asp
  2. try changing the ClearControls sub to Private Sub ClearControls() '*** Clear controls But leave Combobox1 on the form. Dim i As Integer For i = Me.Controls.Count - 1 To 0 Step -1 If Me.Controls(i).Name <> "ComboBox1" Then Me.Controls(i).Dispose() End If Next End Sub
  3. You could also have a parameter passed by reference - a bit more Object Orientated than global variables.
  4. Shared is a VB.Net keyword - use static under C#.
  5. Not near VS.Net at the moment so I may be wrong but I thing the DateTime class can be created from a TimeSpan (I think it is one of the overload new methods). Doing that will allow you to then use the dates .ToLongTime method.
  6. What exactly does the sub do? Changing a sub to a function could be as simple as replacing the word sub with function and giving it a return type - however without knowing what it does it's difficult to say what other changes would be required.
  7. Ahhhh, I get what you mean! Nasty - the only way I can think of doing that is through recursion. Unfortunately my brain is going to sleep about now, I'll see if I get change to look at this tomorrow though. Meanwhile here's a couple of links with regards to recursion that may give you a head start: http://www.csse.monash.edu.au/~lloyd/tildeAlgDS/Recn/Perm/ http://personal.vsnl.com/erwin/magic.htm and I've got to ask because I hate thinking about recursion ;) but why do you need this?
  8. It's probably a rounding error due to the data types being double. Could you not just use Math.round to restrict it to 8 or 9 decimal places? Does seem strange that the values are returned with a rounding error though.
  9. try only doing the line varEveryonesGrade = Math.Round(varEveryonesGrade / sum) after the loop as you are currently going to be shifting the value lower by averaging it every iteration of the loop. The first and second time the varEveryOnesGrade will be correct, but on the third loop you will have divided by one extra time, and again on the 4th etc.
  10. Again you don't need the dynamic for next loop, creating and nesting to that degree will cause the inner most loop to be executed several times. dim writer as StreamWriter 'Set up writer to point to correct file. dim card as CardValue for each card in CardValueArray dim i as integer dim s as string for each i in card.value s= s & i.ToString() & ";" next writer.WriteLine (s) next Wouldn't that write out all values for a given card in a single line? Or do you mean every single combination of every single card and value for the entire CardValueArray?
  11. Without knowing anymore about the error it's hard to say for certain but yes a firewall that hasn't been configured to allow this application to work could be a reason for the error.
  12. So it should be the value of the first item in the first array element in CardValueArray, then the first item in the second element in the CardValueArray - right so far? Does this mean though you will be writing some elements out multiple times? If you are doing this within a series of nested loops some values are going to be written multiple times e.g. in your sample above - every value in the x3 loop will be written one per x2 loop - which will be executed one per x1 loop which also gets executed once every x0 loop! if x0, x1, and x2 only go to 5 each then x3 will be executed 125 times!!!! Could you provide a sample of the data and what you would like the output to resemble, it may clear things up a bit.
  13. grade1 + grade2 /2 -> average of one student. average of all students / number of students = overall average (I think - my stats are a bit rusty) you could simply add a counter to the routine and every time you read a student's details in just increment it.
  14. With .Net you can generate a COM Callable Wrapper (CCW) which allows COM based languages to use the DLL. Read about it, never done it so how well it works is another story....
  15. Do you have access to the file system on the web server? If not this is something the hosting company will need to arrange
  16. again varAverage = Math.Round((Grade1 + Grade2) / 2, 0) varAverage += varEveryonesGrade you are asigning a value to a variable in one line and then simply overwriting it in the next. You seem to be making the problem a lot more confusing and convuleted than it really is. What does the file look like and what are you trying to do? As far as I can tell you want to average a grade for a student from 2 grades and then average this value for X number of students - correct?
  17. As both rekam and Robby have said before - you don't need to dynamically create the for next statements that way, you could use the .Length property of the arrays to write the loop. Or even use a For ... Each loop. dim card as CardValueStructure for each card in CardValueArray dim i as integer for each i in card.Value 'Write i to file next next ...or something similar. Also if you are just saving these values to a file you may want to investigate Serialization in the framework - could save you a hell of a lot of time and effort. something similar to the following would work for serialization Dim fs As IO.FileStream = IO.File.OpenWrite("c:\test.txt") Dim fmt As New System.Runtime.Serialization.Formatters.Binary.BinaryFormatter 'replace with SoapFormatter for SOAP output. fmt.Serialize(fs, CardValueArray) or even have a look at XMLSerialization as another alternative edit: some bad typos and also gave credit to one wrong person as well ;)
  18. The problem could be the '&' it will calculate the (Grade1 + Grade2) bit as a number, then calculate the (varAverage / varEveryonesGrade) as a number and then concatenate the two together as if they were strings. If you put a breakpoint on the line total += (Grade1 + Grade2) & (varAverage / varEveryonesGrade) what does the results of (Grade1 + Grade2) and (varAverage / varEveryonesGrade) look like and how do they compare to the calculated total?
  19. Just somethings you may have missed in there varAverage += 1 varAverage = Math.Round((Grade1 + Grade2) / 2, 0) the second line will always over write the contents of varAverage - the +1 you doing before it is not going to have any effect. also in the line varEveryonesGrade += Math.Round((Grade1 + Grade2) & varAverage / varEveryonesGrade)) what are you trying to do - you seem to be mixing math calculations + and / with string concatenation - &. Is that really what you want?
  20. Dim startTime As Date = Date.Now Dim endTime As Date do something here Dim i As Integer For i = 1 To 10000 Application.DoEvents() Next endTime = Date.Now Dim diff As TimeSpan = endTime.Subtract(startTime) MessageBox.Show(diff.TotalSeconds.ToString)
  21. to do what exactly?
  22. Really depends on what experience you already have. Both languages utilse the same Framework, compile to the same (or very nearly the same) code and give the same performance at the end. The differences are very few and far between.
  23. For most business related applications performance is often far more limited by things like network speed, database (software, design, hardware), overall application architecture and design rather than raw processing power - C# / VB.Net would offer a language that is easier to develop and maintain with fairly clear code (no pointer arithmetic for one) while probably delivering performance similar if not equal to C++ / C++.Net code. If you had parts of the application that were very CPU intensive (lots of number crunching) there may be an argument for using C++/C++.Net - but even then the performance may not improved dramatically. Also as VolteFace said C++.Net will still have large C++ dependencies anyway - it maybe easier to write selected parts as a normal C/C++ DLL instead of using C++.Net
  24. Does that modify backcolor properties for the form / controls on the form? Could you post hte code here?
  25. Cut and pasted your code into a click event handler (and created a new instance) - worked first time. Is there any other code in the form load or paint events?
×
×
  • Create New...