Jump to content
Xtreme .Net Talk

Bucky

*Experts*
  • Posts

    803
  • Joined

  • Last visited

Everything posted by Bucky

  1. He means the period character. In other words, use the native functions of the String class to perform string manipulation, rather than the old VB6 methods. For example, instead of myString = Trim(myString) (bad), use myString = myString.Trim()
  2. Append a ".." to the file name, and it will be smart enough to back up one directory, like so: "C:\Inetpub\wwwroot\Store\admin\..\images\"
  3. You could do a number of things to solve this problem. The most direct, although most difficult, is to write flawless code so that the program is guaranteed not to crash, but this is impossible. A more reasonable option is to have a program running in the background that periodically "pings" your program via the SendMessage API or Sockets. If it doesn't receive a reply, then the program died, and have this background program delete the record.
  4. Dim myProgressBar As New System.Windows.Forms.ProgressBar()
  5. After calling MoveToFirstChild(), check the value of xPath.Name; it looks like the first child is the <config> node rather than the <location> node, so the Name property will be "config". If this is the case, then just call MoveToFirstChild() twice to advance to the <location> node from the <config> node.
  6. Bucky

    Invalid Cast

    PlausiblyDamp is correct, you need to use Date.Parse() to turn the formatted string into a Date; you cannot just set a string to date because they are different types (apparently VB6 converts it automatically). There is an example in MSDN that shows how to convert dates that are formatted for different cultures: [mshelp]ms-help://MS.VSCC/MS.MSDNVS/cpref/html/frlrfSystemDateTimeClassParseTopic.htm[/mshelp]
  7. Or, yet another option, split up the trimmed text into words by using the Split method, and then access the word in an array. Dim s As String = " this is a test " Dim words() As String words = s.Trim().Split(" "c) Console.WriteLine(words(1)) ' Displays "is"
  8. Instead of creating all three iterators at once, create an iterator to loop through each CustomerRet node. Inside this loop, just get the value for the ListID, Name, and Contact by using the SelectChildren() method of the current CustomerRet node. If the child node doesn't exist, the Count of the nodes returned will be 0. For example: 'Begin Xml Dim CustXML As XmlDocument = New XmlDocument() CustXML.LoadXml(response) Dim nav As XPathNavigator = CustXML.CreateNavigator() ' Create an iterator for each customer Dim iCustomer As XPathNodeIterator = nav.Select(nav.Compile("/*/*/*/CustomerRet")) While iCustomer.MoveNext() ' Loop through all customer nodes ' NOW you can get those child nodes Dim iListID As XPathNodeIterator = iCustomer.Current.SelectChildren("ListID","") Dim iName As XPathNodeIterator = iCustomer.Current.SelectChildren("Name","") Dim iContact As XPathNodeIterator = iCustomer.Current.SelectChildren("Contact","") If iListID.Count <> 0 Then ' If a node is found.... ' You *might* have to call iListID.MoveNext() here ListID = iListID.Current.Value ' ... set the value to the string End If ' Do the above for each other value End While This code is untested, but it should give the gist of how you can do it. You may need to use MoveNext before retrieving the values of the child nodes. Good luck.
  9. The Form class has a Visible property, if that's what you mean.
  10. The StreamReader class has a ReadLine method, which reads the file one line at a time. Create a new FileStream to the file, make a new StreamReader to read that stream, then read the line twice to advance it two lines. Then read the third line, set it to a var, and close all the streams. Make sure you import System.IO Dim fs As New FileStream("file path") Dim reader As New StreamReader(fs) Dim i As Integer Dim thirdLine As String reader.ReadLine() ' Read the first line reader.ReadLine() ' Read the second line thirdLine = reader.ReadLine() ' Read the third line and set it to a variable ' Clean up reader.Close() fs.Close() If you wanted, you could also read the entire file into a variable, split it up by newline characters in an array, then access the specific array element to get that line.
  11. What you may have to do is save the image to a new file name, then use the shared methods of the System.IO.File class to delete the original, then move the copy over the original. The bitmap should be disposed of before this. This code would come after the "working approach": b1.Dispose(); // Clear up any resources System.IO.File.Delete(FullFilePath); // Delete the original System.IO.File.Move(FullFilePath + ".copy.jpg", FullFilePath) // Move the copy over
  12. I'm not a C++ expert, so I don't know what's wrong with the strings. However, it is worth pointing out that an Integer variable in VB6 is 16-bit, whereas an Integer in VB.NET (and the whole .NET framework) is 32-bit (the Int32 object). Make sure that the number you're returning in the DLL is the same size as the variable you're setting it to, as this could be causing the number problem.
  13. Another option is to, before binding the DataTable to the DataGrid, is to loop through all the rows and modify the Day column to only include the date. You can convert the date to a DateTime variable by using DateTime.Parse(). The day of month is in its Day property, then just set this back to the column. Dim dr As DataRow For Each dr in ds.Tables(0) ' Loop through each row Dim theDate As DateTime = DateTime.Parse(dr.Item(0).ToString()) ' Assuming 0 is the Day column, set it to a DT variable dr.Item(0) = theDate.Day ' Set the day of month as the new value Next
  14. Actually, the correct syntax is: CBox.CheckState = CheckState.Checked
  15. Yes. Within one Solution you can have multiple projects, each with its own language. If you have a VB.NET project and you want to reference some classes in C#, create a new C# class module project, write the code, and then reference the C# project in the VB.NET project by going to the project references, then the Project tab.
  16. Bucky

    vbcrlf

    Set the Multiline property of the textbox to True to allow for multi-line characters to be displayed correctly. As for your concatenation, it looks like you have two different names for the same textbox: SumTBox and SumTextBox. Which is it? Also, use the & operator for concatenating strings together, and keep the + operator for adding numbers; it's a better practice.
  17. If I understand correctly, you can serialize an object, then you can encode it in a string and store it in a ViewState variable, then decode and then deserialize the string to get the object back.
  18. The MessageBox.Show() method pops up a Windows message box with a variety of options, although the only options you have for pictures are the standard Windows ones: error, information, question, etc. If you want a message box with your own graphic, you'll need to make a form and show it by using the ShowDialog() method.
  19. This is incorrect. If the function or method (or variable, constant or anything else) is declared as Public, it can be accesed through any instance of the form.
  20. Can you show the code you used to attempt to decrypt it?
  21. The System.Security.Cryptography namespace provides classes for encrytion and hashing. Read all about it [mshelp=ms-help://MS.VSCC/MS.MSDNVS/Cpqstart/html/cpsmpnetsamples-howtocryptography.htm]here[/mshelp].
  22. Do you mean drag-and-drop during design-time or during runtime?
  23. Depending on the encoding of the byte array (ASCII, UTF8, etc.), there are different classes for conversion from byte arrays to strings and back. If the encoding is ASCII, for example, you would do this, assuimg b is the byte array and s is a string: s = System.Text.Encoding.ASCII.GetString(b)
  24. Mod is a mathematical operator that does division and returns the remainder. The \ is a division operator that returns a whole number without the remainder. So, if l is the Long (it should be an Integer, actually, since that is 32-bit), then... Dim x, y As Integer x = l Mod 65536 y = l \ 65536
  25. An Integer in VB.NET is a 32-bit number variable, which is the same as a Long in VB6, so you do not need to convert the params and messages to Longs. You can convert the Integer into an IntPtr if the parameter is a handle to a window, an hDC, or anything of that nature. Then you can use the IntPtr in .NET functions. I don't completely understand your other questions... Do you already know how to subclass (override the WndProc method)?
×
×
  • Create New...