Jump to content
Xtreme .Net Talk

Volte

*Experts*
  • Posts

    2372
  • Joined

  • Last visited

Everything posted by Volte

  1. Use the myButton.PointToScreen(myButton.Location) to get the location of the button on the screen, rather than relative to the form.
  2. You can use the Graphics.MeasureString function to get the size of text.... something like this: Private Function TextWidth(ByVal text As String) As Integer Dim g As Graphics Return g.MeasureString(text, New Control().Font).Width End FunctionIf your checkboxes use a non-standard font, replace the bit New Control().Font with myCheckbox.Font or whatever. Otherwise it just uses the default control font.
  3. If you use an Application.DoEvents, inside the loop, it will allow other messages (e.g. painting to get through). You better disable or hide the necessary controls though, because your user will still be able to click on buttons, which can really mess things up. [edit]D'oh![/edit]
  4. String.Remove is one way, but you can also use String.Substring, specifying String.Length - 8 as the start position.
  5. The TypeConverterAttribute (attributes being the < > tags that precede some classes) tells VB what TypeConverter to use in the designer. In this case, it converts it to a format that the property window knows how to interpret and respond to accordingly. You could write your own TypeConverter as well, if you wanted.
  6. Ok, then try something like this:Dim tmp As Controls For Each tmp in Me.Controls If TypeOf tmp is CheckBox Then If DirectCast(tmp, CheckBox).Checked Then 'code End If End If Next
  7. You can use a For Each loop to go through all the checkboxes. Dim tmp As Checkbox For each tmp in GroupBox1.Controls If tmp.Checked Then 'code End If Next
  8. True, but if you want to practice good coding standards, then you use System.IO. You can use Goto and On Error and FileOpen and all the rest of the Vb6 compatability functions, but you shouldn't. They are not really supported by the .NET framework. As a general rule, I don't use anything that can't be used in both C# and VB.NET.
  9. :eek: mutant! No! Never ever ever use FileOpen and related functions. They are provided for backward compatability (so that the program migration wizard doesn't have to convert the old VB6 way to the new .NET way), and should be avoided like the plague (at least, in my opinion). Awful coding practice, those functions. The System.IO namespace is what you use.
  10. You should declare 'Line' and 'i' as Strings, as that is what is stored and retrieved from text files. Other than that, it looks like it should work.
  11. It means you're trying to access an array element that is not in the array (for example, accessing myArray(100) when myArray only has 20 elements). I think there is a major flaw in your logic. Your code would only work if the user typed 30 words or more in the txtEnglish textbox. I'm sorry I can't really help you more, but I don't totally know what your problem is. :-\
  12. Ok, try this:dim rm(30,3) as string Dim English, French, As String Dim i, where As Integer Dim Fword(30), Eword() As String Dim found As Boolean English = TxtEnglish.Text Eword = English.Split(" "c) For i = 0 To 30 Do While ((Not found) And (where < rm.Length)) found = (Eword(i)) = rm(where, 0) where = where + 1 Loop where = where - 1 Fword(i) = rm(where, 1) Next TxtFrench.Text = Join(Fword," ")
  13. It looks like you're never giving EWord any subscripts; you declare it as Eword() (so you need to use Redim to dynamically size/initialize it), but you never assign anything to it; you just get data out of it. Perhaps when you say Fword = English.Split(...) you really mean Eword = ...? Also, you are going to need to give Fword an upper-bound. From the way the code works, I'd say you could just change the declare from Dim Fword() ... to Dim Fword(30) ...
  14. What error are you getting? It looks like your code structure is a little off. Perhaps you could explain exactly how your code is meant to work (what is rm?) and we could help you structure it better.
  15. I thought the UInt16, UInt32, and UInt64 types were unsigned integers.
  16. I don't quite understand your dilemma, but you can't just make the drawing scroll automatically. You need to make your painting sub draw the image in the same place all the time (0,0 I would assume), but only draw a portion of it based on the position of the scrollbars.
  17. You can, however, serialize objects into XML or binary; look into the Xml.Serialization namespace to serialize to XML, and the System.Runtime.Serialization.Formatters.Binary namespace to serialize to binary. What serialization does is take all the properties of an object and store them in a file or in memory so you can store them easily (to send over the internet, store settings, etc).
  18. It looks to me like you are just clearing the label every time you iterate through it. You set the label's text to IntNumber & Environment.NewLine & lstNumber.SelectedItem, and then you do that 2 more times; it's not appending, just changing the text. To fix this, change the code to this: Private Sub btnPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrint.Click Dim IntNumber As Integer lblPhrase.Text = "" For IntNumber = 1 To Val(lstNumber.SelectedItem) lblPhrase.Text &= IntNumber & Environment.NewLine & lstNumber.SelectedItem IntNumber = IntNumber + 1 Next IntNumber End SubNotice I changed it to a For loop, because that is more appropriate in this case. The differences between them can be found in your MSDN if you're curious. Also, notice I changed the operator used to change the label to &=, which appends text to the label, rather than just changes it.
  19. If you put your drawing code in the Paint event of your form, you can use the Invalidate method of your form to force a repaint.
  20. Look here for an example of playing music with mciSendString. It's VB6, but it should be similar. Download the APIViewer2002 if you want an API viewer which supports .NET declarations.
  21. Remember that arrays are 0 based, so you need to start whatever loop you're using at 0, not 1. Post some code so we can see.
  22. It's to prevent spamming and flooding. You'll have to live it with. :p
  23. In that case, you will need to do some work. Date parsing is a very complicated thing, in that you can have many different formats, orders, styles, delimiters and not to mention leap years... In my eyes, this exercise is needlessly complicated, but then again I'm not the instructor. :-\
  24. You can use the IsDate function. If Not IsDate(fullDate) Then MessageBox.Show("Invalid Date!") End If
  25. Actually, API Viewer 2002 from AllAPI has native support for VB.NET declares (although its not 100% accurate when it comes to fixed strings and fixed arrays and such, it makes live easier still).
×
×
  • Create New...