Jump to content
Xtreme .Net Talk

Cags

Avatar/Signature
  • Posts

    699
  • Joined

  • Last visited

Everything posted by Cags

  1. If you don't want to return a dataset do something like this... Private Sub myFunction() Dim mySet As DataSet mySet = getDataSet() If mySet Is Nothing Then ' handle null value Else ' proceed with dataset End If End Sub Private Function getDataSet() As DataSet Dim mySet As DataSet Try mySet = New DataSet Return mySet Catch ex As Exception Return Nothing End Try End Function
  2. I'm not entirely sure what the line you wanted to create was, but heres how you do it string sName = "Shaitan00"; string sString = @"The man said ""Hello " + sName + @"""" + " this is a quote."; If you want to represent a double quote in a string literal, the escape sequence is two double quotes. Also using @ tells c# to use the literal values for example you could make a path reference as the following without the escape characters for each \. string sPath = @"c:\documents and settings\bob\my documents";
  3. Try this <td><xsl:value-of select="UDF/Name/NameFirst" /><xsl:text> </xsl:text><xsl:value-of select="UDF/Name/NameLast" /></td>
  4. When you say it didn't work what do you mean, the image didn't appear at all, it didn't appear in the place you wanted it to, or it wasn't the size you wanted it?
  5. Try setting the KeyPreview property of the form to true. This registers the key events of each control to the forms key events.
  6. Using the example you specified you need to ensure that a dataset is always returned. If your database call returns null then you either have to return a null dataset (in which case you should check for this in the place you call the function to prevent null reference exceptions) or as you say you could create a new dataset manually and return that. What you shouldn't do is naturally exit the function without a return Dataset statement.
  7. An application which I have been working on recently started throwing up this error message whenever I try to debug it, has anyone got any idea what it means? An unhandled exception of type 'System.OutOfMemoryException' occurred in system.windows.forms.dll Additional information: Error creating window handle. Stepping through the code shows the constructor of the form steps through correctly, but then it crashes out as soon as entering the Main() method.
  8. Basically VisualStudio is warning you of a potential problem in your program. I don't know much about vb, but heres a c# example hopefully it will be self explanatory. // function that returns a boolean private bool MyFunction() { if(a == b) { return true; } } In this example a simple function checks if two objects are equal, if they are it returns true, if they aren't the function doesn't return a value. VisualStudio is simply informing you that a logical code path through your function doesn't return a value. This can cause crashes in your application if for example you do.. Dim myBool as Boolean myBool = MyFunction() If myBool = True Then 'do something End If If MyFunction ends up following the logic path in MyFunction that doesn't return a value this could cause your application to crash.
  9. If you wish to return a property of a child object you can do something like the following, basically you just make a property of the type of the childs property... public class ObjectA { public string Name { get { return "Object A"; } } } public class ObjectB { private ObjectA objA = new ObjectA(); public string ObjAName { get { return objA.Name; } } } Does this answer your question?
  10. Hmm.. Just noticed I neglected to mention the fact I would use the XmlTextReader class (myReader = new XmlTextReader), I'm assuming this is accessible through Asp.
  11. I can't say I know a thing about asp.Net, but using c# its simply a case of something along the lines of this... string sTitle = ""; while(myReader.Read()) { if(myReader.NodeType == System.Xml.XmlNodeType.Element) { if(myReader.Name == "Title") { sTitle = myReader.ReadInnerXml(); } } } Using this method you check for the main node of each item, then create the row. Then cycle through each property to read in the column information. I'm not sure if this helps you, but I hope it does.
  12. As I mentioned previously one solution would be to turn off the Sorted property and place the items in the array manually. To do this you need to cycle through the values currently in the array checking if they are smaller than the one you wish to add, if you find one that isn't you simply add your new item before that. I've never actually really used VB.Net but I think this is the right syntax... Dim i As Int16 Dim bNotAdded As Boolean = True While bNotAdded If i < lstMedian.Items.Count Then If CInt(lstMedian.Items.Item(i)) < add Then i += 1 Else lstMedian.Items.Insert(i, add) bNotAdded = False End If Else lstMedian.Items.Add(add) bNotAdded = False End If End While Perhaps not the most elegant solution but it would work. Alternatively you could write a method (sub) to sort the array yourself (using a bubblesort algorithm or something similar) and call this every time you add an item.
  13. private enum Status { CONTINUE, WON, LOST }
  14. Well as far as I know the strings in .Net are immutable, which means they can't be changed only reassigned, this being said I feel your best option is to look into preventing the flicker. You might get more help if you explain exactly how much text your talking about and why your working with such big strings.
  15. I'm not entirely sure if I understood you but it sounds like you wish to remove a character although the Backspace key has been pressed. Since pressing backspace in a textbox will achieve this anyway i'm assuming you are creating your own. Either way if I understand you correctly you can use this. textBox1.Text = textBox1.Text.Remove(textBox1.Text.Length - 1, 1); Obviously that will delete the last char, you could easily modify it to delete a different char or strech or chars. As for whether this is any more effecient than what your currently trying I don't know. But as far as I know theres no easy way of removing a char without assigning a new string to the Text property.
  16. Cags

    Bottleneck

    Thanks for your help I've worked out what was causing the slowdown, I was using the wrong variable when creating the array, making it 40 * wider and 40 * heigher than it should have been (hence an attempt to draw a hell of alot more rectangles than I thought it was drawing). On a side note Nerseus thats a reasonable approximation of my application the only real differences are that I'm using a [,] array currently not [][] and also I'm doing the drawing in a seperate method (to a bitmap which is painted to the screen in the OnPaint event).
  17. Cags

    Bottleneck

  18. Cags

    Bottleneck

    I tested drawing 1581 rectangles with code along the lines of Rectangle rectBounds = new Rectangle(0,0, 5, 5); // same size as those in the array; for(int i = 0; i < 1581; i++) { gBuffer.DrawRectangle(Brushes.Black, rectBounds); } This code actually draws 1581 rectangles and it is worth noting that using my original code 375 squares are nodes, and these are the only ones actually being drawn. The squares of SquareType Link are all LinkType Unknown. This is why I came to the conclusion that the DrawRectangle is not the line of code causing significant slowdown. With regards to the for being quicker than a foreach, I have tried both and found foreach slightly quicker (this was probably due to referencing the array item multiple times, rather than a local object which is created with a for each loop).
  19. I think (somebody may well correct me) but the differnce is this. When you are adding a panel to another panel using the designer it logical just changes the parent of the control your adding to the panel control you add it to but all the objects are still in the same scope. But when you have a panel added to a user control its properties are wrapped and hence cannot be fully accessed by the designer as they are in a different scope.
  20. Cags

    Bottleneck

    I've written a small section of code that takes alot longer to complete than I think it should. The code is actually using a Graphics object but I put this post in the General forum as I believe the bottleneck has nothing todo with the actuall drawing. The following code takes approximately 480ms to complete (whereas simply drawing the equivalent number of rectangles takes about 9ms). foreach(Square sqTemp in arrGrid) { if(sqTemp.Type == SquareType.Node) gBuffer.FillRectangle(Brushes.Black, sqTemp.Bounds); else if(sqTemp.Type == SquareType.Link) { if(sqTemp.Link == LinkType.Yes) { gBuffer.FillRectangle(Brushes.Black, sqTemp.Bounds); } else if(sqTemp.Link == LinkType.No) { gBuffer.FillRectangle(Brushes.Red, sqTemp.Bounds); } } } Given.... Square[,] arrGrid = new Square[31,51]; public enum SquareType { Node, Link, Number } public enum LinkType { Unknown, Yes, No } Class square is a small class with properties for Bounds, LinkType and SquareType. I was originally using a nested for loop to cycle through each square, but found that using a foreach loop was slightly quicker. I'm wondering if using Square[,] is not a good method of creating an array, maybe I should build a custom collection by inheriting collectionbase. Has anybody got any ideas on the best way of speeding up this method? (as my application is relatively simple I can always get around it by drawing only parts of it at a time, I just thought I'd check to see if anyone notices an obvious bottleneck first)
  21. I haven't tried your code but after looking at it I'm slightly confused by this line cCanDrop.Location = New Point(picCanDrop.Location.Y - 20) I'm assuming theres some kind of typo here for 2 reasons. Firstly surely there should be an x and y coordinate specified in the new point. Secondly and perhaps the thing causing you trouble, as you are deducting from the Y value it will actually move upwards (since 0 is the top of the page) and thus will always be less than 360. Obviously that could also be a typing mistake but I thought I'd mention it. You could use the timer object like so to achieve the effect your after... Public iCount As Int16 Public iOld As Int16 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Timer1.Interval = 250 iOld = Button1.Top Timer1.Start() End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Button1.Top += 10 iCount += 1 If iCount = 10 Then Timer1.Stop() Button1.Top = iOld End If End Sub EDIT:- Obviously my example moves a button not picturebox, but thats kinda irrelevant.
  22. A dll doesn't implement anything it's simply a library of classes. Any or all of the classes in the dll can implement the same interface. The fact that classes are all in the same dll doesn't link them in any way other than the fact that they are stored together.
  23. That is probably what he meant by populating. If you are adding the items one at a time you could work out its position manuallly before adding it (obviously you would have to set the sort property to false to false) with the InsertAt property as opposed to the Add method.
  24. If you wish to select the item with the text "2" you can use ComboBox1.SelectedIndex = ComboBox1.Items.IndexOf("2") or if you wish to select the second item regardless of what it is ComboBox1.SelectedIndex = 1
  25. Ok I don't know much about VB.Net, but if you wish to compare the colour of the pixel you will need to use ToArgb() method of the color object. So for your example black.ToArgb() EDIT- ok marble beat me to an answer again
×
×
  • Create New...