Jump to content
Xtreme .Net Talk

Bucky

*Experts*
  • Posts

    803
  • Joined

  • Last visited

Everything posted by Bucky

  1. System.Math.Abs()
  2. Bucky

    Module

    Okay, I've figured out the problem, and I've been telling you some misinformation. The Shared keyword works differently when used on variables than it does when it's used on methods. When you have a Shared Sub or Function, that method can be seen and used without initializing the class. That's what I said. When you have a Shared variable, however, that means the value of that variable is shared between multiple instances of that class. I'd reccomend you read [mshelp=ms-help://MS.MSDNQTR.2003FEB.1033/vbcn7/html/vaconSharedMembers.htm]this article[/mshelp] before I confused you further. Sorry for the misinformation, and I hope the article clears things up.
  3. Bucky

    Module

    You forgot the keyword "Class" when defining the classes Experimental and RGB_HSL_RGB. You also don't declare the class itself as Shared, you only declare the methods and variables within it as Shared. It also helps to avoid confusion by giving namespaces and classes different names; don't call them both Experimental.
  4. Bucky

    Module

    If you declare all the methods of Class1 and Class2 as "Public Shared", then you should have no problem accessing the methods between the classes and between your sub. You do not need to inherit Class1 just to access its variables; if they are Public Shared then Class2 will be able to see them. Both classes should also be in the same namespace. If you don't define a namespace, then your project itself is a namespace and it will group the classes.
  5. Bucky

    Module

    Let's take your previous code as an example. Because the two methods do not require access to instance-specific members such as private variables in the class, you can declare them as Shared (static in C#). That way you can call the method without having to Dim a new instance of the class. So, here's the modified class: Public Class HELLO Public Shared Function Maximum(ByVal a As Single, ByVal b As Single, ByVal c As Single) As Single ... End Function Public Shared Function Minimum(ByVal a As Single, ByVal b As Single,ByVal c As Single) As Single ... End Function End Class And here's the code that calls it: Public Class Yoyo Private Sub MySubProggy(ByVal hello As Byte) ' No need for Class1 here Max = HELLO.Maximum(A, B, C) Min = HELLO.Minimum(A, B, C) End Sub End Class The same can be done for variables.
  6. You're trying to exit the application in the constructor of the form. Because the form hasn't been successfully initialized yet, it has not returned a value and Application.Run() never even gets a chance to run the form because it hasn't been initialized. I'd suggest placing the code inside the form's Load event, instead.
  7. I knew you would, PD, judging by your avatar. :)
  8. Bucky

    Module

    Instead of organizing your code into modules, organize it into classes instead. You can create methods that do not require an instance of the class to be run, just declare them as Shared. If you would like to group several classes together for aesthetic quality and overall organization, then place all the classes in the same namespace (just declare Namespace (name) above the classed and an End Namespace after them).
  9. Bucky

    Module

    If you want the consumer of the class to be able to access members (properties, methods, events, etc.), then declare them puclicly as you have done. Otherwise declare them Private or Protected. You do not need to destroy of classes when you are done with them to free memory, as was necessary in VB6. Objects that implement the IDisposable interface (mostly GDI+ classes), however, should be disposed of when they are done being used to free their memory. You can identify these classes because they have a Dispose() method. Also try to avoid using Modules and organize your classes into namespaces. To create "global" methods, declare members of a Public class as Public Shared.
  10. In case you were wondering, the problem lies in this line: nColor = ColorHLSToRGB(63, 0.9176471, 0.952381) Since the API only accepts integers, the last two parameters were rounded off.
  11. The call to the webservices should stop the code in the ASP.NET application until a result is returned; I don't understand what the problem is.
  12. This is a fairly complex thing to pull together, but it can be done. You will need a good understanding of how the Sockets namespace works (and there are plenty of examples in the SDK documentation). Then it's just a matter of using a TcpClient or some other Socket to connect to your computer (assuming you have an IP that's relatively static) and have a host app running on your computer to accept the connection and send the update by converting it into an array of bytes and sending it along in small chunks. The update itself could be in the form of a DLL of functions that your program references, and it copied over when the program is not running. Or you might choose to update the entire exe. Either way, I will point out that you will need to close the main application and have another app to update the main app.
  13. Can I quote you on that? ;)
  14. Are you connecting to some server that already exits, or are you writing both the server and client applications? If you're writing them yourself, I'd highly reccomend creating an XML Web Service that hands out data. It's very easy to implement these services in ASP.NET and Windows applications. If you're trying to access data that's already in some other form, then you're going to have to manually download it (with Sockets or a WebClient) and parse the data out of the string.
  15. If you just want to append an "A" to the text, then just add it on to the Text property: TextBox1.Text &= "A" If you want to fire the KeyPress event in addition, then just call it like you would any other sub, creating a new KeyPressEventArgs and passing it to the event handler: Dim args As New KeyPressEventHandler("A"c) TextBox1_KeyPress(Me, args) Will that work?
  16. Your best bet would be to define a whole bunch of rectangles or regions at runtime, and store them in a two-dimensional array. Then, in the MouseDown event, loop through each region/rectangle to see if the click was contained within that area (using the Contains() method).
  17. I believe I know the problem. I'll bet that you're populating the ListBox every time the page loads, right? If that's the case, then when you click Accept the ListBox is re-populated and your selected item is lost. What you need to do is, in Page_Load, check Page.IsPostBack to determine if the page is being posted back to the server (through and event like a button click) or is being requested for the the first time. So, in Page_Load: If Not Page.IsPostBack Then ' If being loaded for the first time ' Populate the ListBox here End If David, even if the Name or Value of the SelectedItem were null, an empty string would be concatenated; an error would not be thrown. [edit]Eek, post 666![/edit]
  18. Is this is a TextBox on your form, or is it a TextBox in another running application?
  19. I don't know if this is possible, but you could try this approach. Add a runat="server" attribute to the PARAM tag, like so: <PARAM NAME="image_pan_tilt" VALUE="" runat="server" id="imagePanTiltParam"> Then, in your code-behind page, declare an HtmlGenericControl in the General Declarations section of the code: Private imagePanTiltParam As HtmlGenericControl Then just change its attributes from your code: imagePanTiltParam.Attributes("value") = "the new value goes here" It's a long shot, but it's worth trying.
  20. Oh, 5 rows... I thought you meant columns. If that's the case, then declare a new DataSet that has the same columns as your data, and then add five blank rows to it. Then set the DataSource property of the grid to the DataSet and DataBind() the grid.
  21. You need to add the attribute runat="server" to the tag that defines the control on the web page. Then VS.NET should automatically create a declaration for the control in the code-behind page. If it does not, you can always declare it manually.
  22. I myself like to use an ArrayList class to manage arrays or collections. That way you can easily add, remove and reorder items. If you wanted to add all the panels in the ArrayList to a panel control using, say, StatusBar.Panels.AddRange(), you could always create an array out of the ArrayList by using ArrayList.ToArray().
  23. Are the columns going to hold data from a data source, or do you want to define your own columns?
  24. The problem does not lie in the setting of the variable to a Session variable; it lies in the declaration of objProduct. Make sure that the page has the correct Imports statement to import the namespace that Product is declared in.
  25. Bucky

    String issue

    Yes, use the Split method. Then convert each color into an integer and create a Color structure. Dim MyColors() As String MyColors = MyString.Split(" "c) ' Split MyString by space characters Dim red, green, blue As Integer red = Convert.ToInt32(MyColors(0)) green = Convert.ToInt32(MyColors(1)) blue = Convert.ToInt32(MyColors(1)) Dim MyColor As Color = Color.FromArgb(red, green, blue)
×
×
  • Create New...