PlausiblyDamp
Administrators-
Posts
7016 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by PlausiblyDamp
-
Cut and paste would involve more maintenance if the navigation strip ever needs to be updated. Surely a user control that contains nothing more than static HTML is no more of an extra layer than an include file that contains static HTML.
-
Could you clarify what you mean by 'What a waste'? A static (or fairly static) usercontrol isn't hard to create by anymeans and can be added to any aspx page with a couple of mouse clicks.
-
Feeling bored so you might want to try this. I've created a basic Combobox control with the functionality built in, not a complete control by any standards but a good starting point. Create a new WindowsControl Project and paste this into a new class module and have a play. Public Class AutoCompleteComboBox Inherits System.Windows.Forms.ComboBox Protected Overrides Sub OnKeyPress(ByVal e As System.Windows.Forms.KeyPressEventArgs) Dim sText As String = Text Dim i As Integer If e.KeyChar = Convert.ToChar(Keys.Back) Then Text = Text.Substring(0, SelectionStart - 1) sText = Text End If i = FindString(sText) If i >= 0 Then SelectedIndex = i [select](sText.Length, Text.Length) End If MyBase.OnKeyPress(e) End Sub End Class
-
I personally would tend towards user controls. They are pretty easy to build, have serverside code and can also perform fragment caching so the control's HTML is generated once and reused multiple times. Frames are pretty horrible and using server side code with them is IMHO a nightmare. Include files will work but I find usercontrols a more object orientated way of doing things.
-
Never tried it at all - but I'm not averse to having a play with it if you have any problems ;)
-
Not used it much myself but after see this post and the other one you posted (and fixed) I thought to ask if you are doing this via COM and C++ (seems to be the case)? If so have you looked at the System.Management.Instrumentation namespace (you will need to add the appropriate reference)?
-
also noticed there is a lot of VB6 code in there - was this converted by the upgrade wizard? If you want to drop the compatability stuff the following is a more .Net way of doing things. (Although replacing the chr function can make it a bit long but more readable) Public Const CB_SELECTSTRING = &H14D ' API Declarations Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" _ (ByVal hwnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, _ ByVal lParam As String) As Integer Private Sub cmbCity_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles cmbCity.KeyPress Dim APIRetVal As Integer Dim sText As String With cmbCity If Not (e.KeyChar = Convert.ToChar(Keys.Back) Or e.KeyChar = Convert.ToChar(Keys.Escape) Or e.KeyChar = Convert.ToChar(Keys.Enter)) Then If .SelectionLength > 0 Then sText = .Text.Substring(0, .SelectionStart) & e.KeyChar Else sText = .Text & e.KeyChar End If APIRetVal = SendMessage(.Handle, CB_SELECTSTRING, -1, sText) If APIRetVal <> -1 Then .SelectionStart = sText.Length .SelectionLength = .Text.Length - .SelectionStart + 1 Else .Text = sText .SelectionStart = sText.Length + 1 End If e.Handled = True End If End With End Sub
-
change the KeyAscii = "" to e.handled =true.
-
quick and easy way is to use a TimeSpan Dim ts As TimeSpan ts = TimeSpan.FromSeconds() MessageBox.Show(ts.ToString())
-
If the date parts were seperated by a character other than a : you could use DateTime.Parse Dim d As DateTime d = DateTime.Parse("2003/10/31 22:34:52")
-
Adding Dot Net Framework to the Setup Project in Dot Net Solutions.
PlausiblyDamp replied to ns2k's topic in Deployment
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconusingsetupexebootstrappersamplewithapplication.asp -
In the current account declare the function as public override bool CanDebit(double amount) { if (amount <= balance + overdraftLimit) { return true; } else { return false; }
-
If the function is required by the base class then it needs to be defined in the base class. You could add an abstract function to the base class though and only implement it in the sub class. using System; namespace Reeks6 { abstract class BankAccount { //constructor public abstract bool CanDebit(double amount); public void Debit(double amount) { if (CanDebit(amount)) { balance -= amount; Console.Write("Debit succeeded "); } } } } edit : typo
-
QueryBinaryValue for registry
PlausiblyDamp replied to eran's topic in Directory / File IO / Registry
Dim rk As Microsoft.Win32.RegistryKey rk = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey("*", True) rk.CreateSubKey("shell") -
Just curious as to why are you using CType to convert strings to strings in the serializing bit. The .Text properties are already a string.
-
QueryBinaryValue for registry
PlausiblyDamp replied to eran's topic in Directory / File IO / Registry
Does that registry key exist in your registry? (Do you mean shell not shel)? Also why use the APIs when .Net provides classes to access the registry anyway? Dim rk As Microsoft.Win32.RegistryKey rk = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey("*", True) Dim b() As Byte b = DirectCast(rk.GetValue("test"), Byte()) b(1) = 43 rk.SetValue("test2", b) The value of test wsa added just for this sample. -
Does the BankAccount's CanDebit have any implementation or is it marked abstract? If it contains implementation then CurrentAccount will automatically gain the CanDebit functionality. If you wish to replace the BankAccount implementation with a new one then you will need to make the base class version virtual and override it in the sub class. Is there any code you could post that could give a better idea of what you need to acheive?
-
What should I avoid to keep the .exe file a stand alone program?
PlausiblyDamp replied to FartNocker's topic in Deployment
If you have manually added any references to your project (Project menu - add reference or through the solution explorer) then those dlls will need to be shipped. If you have any third party controls in the toolbox then the relevent files (licensing permitting) will alos have to be deployed). -
You may want to look at the Xml.Serialization.XmlSerializer class. There are a couple of pretty good samples on how to use it in MSDN.
-
What should I avoid to keep the .exe file a stand alone program?
PlausiblyDamp replied to FartNocker's topic in Deployment
You will also need to ensure the Framework is installed on the target computer so a pure stand alone executable isn't really possible until the Framework is part of the standard OS. Adding classes or modules will not require extra files to be shipped but setting references to other .Dlls will require those Dlls to be shipped as well. -
You could use a try ... catch block around the line or just check it first Dim srdr As StreamReader = New StreamReader("map/test/test.txt") Dim LineCount As Integer Dim ln As String Do LineCount += 1 ln = srdr.ReadLine() MessageBox.Show(ln) 'May be a bit of a nasty hack but should work. If ln.ToCharArray Is Nothing Then Exit Do Dim ch() As Char = ln.ToCharArray For Each c As Char In ch MessageBox.Show(c.ToString()) Next Loop Until ln Is Nothing srdr.Close()
-
'Naff class to work with Public Class TestClass Public thing As String Public Otherthing As Integer End Class 'start of a collection of test classes Public Class TestList Inherits ArrayList Public Shadows Sub Add(ByVal Test As TestClass) MyBase.Add(Test) End Sub Public Shadows Property item(ByVal Index As Integer) As TestClass Get Return DirectCast(MyBase.Item(Index), TestClass) End Get Set(ByVal Value As TestClass) MyBase.Item(Index) = Value End Set End Property End Class should be a reasonable starting point for a collection class - you may need to override / shadow other functions depending on your requirements. You can then use it similar to Dim MyList As New TestList Dim x As New TestClass MyList.Add(x) Dim y As TestClass y = MyList(0) 'etc.
-
Sprite Sizes with Tile sizes
PlausiblyDamp replied to ThePentiumGuy's topic in Graphics and Multimedia
Positioning, pathfinding etc would probably be easier if they were the same size or smaller. That way a tile is either walkable or not - removes the need to do alot of collision detection just to determine if a route is traversable. Some collision detection will be required to prevent objects moving through the edges of non-passable tiles though. -
Do you have any documentation / knowledge of how this value is obtained? What unix command are you using to generate this value?
-
Just my lazy naming convention;) ch() is the string turned into an array of characters, c will contain an individual character. The for each c as char in ch just loops through them one character at a time. The syntax is just a shorthand way of doing for each loops in VS.Net 2003 For Each c As Char In ch MessageBox.Show(c.ToString()) Next 'same as dim c as char for each c in ch MessageBox.Show(c.ToString()) Next