PlausiblyDamp
Administrators-
Posts
7016 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by PlausiblyDamp
-
If you bring up a command prompt and type ipconfig it should tell you your TCP/IP address and subnet mask. If you could do that on both the client and server what are the values for ip address, subnet mask and default gateway? Setting a proxy server wouldn't really help as that will only be used by IE for access to the internet.
-
What is the IP address and subnet mask of both the client and server?
-
I've hard coded the string but you should get the idea. Dim s As String = "Sc0pe:12.34.56.78" Dim i As Integer = s.IndexOf(":") Dim s2 As String = s.Substring(i + 1, s.Length - i - 1)
-
You could simply create a variable of type WebClient and get it to download the contents The following will download this thread in to a string Dim b() As Byte Dim wc As New System.Net.WebClient b = wc.DownloadData("http://www.xtremedotnettalk.com/showthread.php?t=87115") Dim s As String = System.Text.ASCIIEncoding.ASCII.GetString(b)
-
If you put localhost into the serverbox field and run the server locally does it connect? If so things are still okay. If you run the server remotely and put the server's name or ip address in serverbox does it now fail to connect? If there is a firewall between the two boxes then this is probably blocking access to certain (most) ports and will prevent connection - you will need to either convince the network administrator to open the relevant port (may be hard to convince though) or try and run the server and client portions of the project on two machines without a firewall between them. The warning you are getting about myListener = New TcpListener(myport) simply means that this is no longer the recomended way to setup a listner and this may not be supported in a future version of the framework. You should probably use the following code instead myListner= New TcpListner(IPAddress.Any,myport)
-
Did a quick test: Public Sub test1() Dim i As Integer = 3 While i < 100 i += 1 End While End Sub Public Sub test2() Dim i As Integer = 3 Do While i < 100 i += 1 Loop End Sub both produced the same MSIL { // Code size 14 (0xe) .maxstack 2 .locals init (int32 V_0) IL_0000: ldc.i4.3 IL_0001: stloc.0 IL_0002: br.s IL_0008 IL_0004: ldloc.0 IL_0005: ldc.i4.1 IL_0006: add.ovf IL_0007: stloc.0 IL_0008: ldloc.0 IL_0009: ldc.i4.s 100 IL_000b: blt.s IL_0004 IL_000d: ret } no difference between them.
-
When you say it still isn't working what errors do you get? What are you putting into the serverbox field (ip address of remote server, server name etc.)? Also when you say the line myListener = New TcpListener(myport) has the error indicator on it if you hold your mouse over the line what error appears in the tooltip? As to the other ideas: is there a firewall between you and the other computer?
-
You could use regular expressions to validate the string (search these forums and you'll will find a few samples), or alternatively you may want to use the double.TryParse(...) method - incidently if you look at the VB IsNumeric function in ildasm then it actually calls the TryParse method itself anyway....
-
One of the overloaded methods of the MenuItems collection allows you to specify a position. Given an already existing context menu you could do Dim m As New MenuItem("Fred") ContextMenu1.MenuItems.Add(0, m) to add a new item to the top of the list.
-
In the client code you need to modify the line myclient = New TcpClient(portbox.Text) to include the address of the server you need to connect to i.e. myclient = New TcpClient(serverbox.Text, portbox.Text) where serverbox is another textbox on the form allowing a user to enter the servers name or address.
-
You could serialize the GraphicsItem ArrayList and store that in the DB - just associate it with the number the user entered. This could then be deserialized when the form is 'loaded' from the DB - if you need to keep the items editable this should work - if you just store the resulting image then you wouldn't be able to edit the items later.
-
Could you post your existing code - it makes it easier to troubleshoot if we can see what is going on? How are you currently connecting to the server from the client?
-
Something similar to Server.MapPath, in windows applications
PlausiblyDamp replied to dhj's topic in Windows Forms
Application.StartupPath will return the folder the executable is in if that is what you mean? -
In that case you could just use a recursive function to find controls nested inside other controls. http://www.xtremedotnettalk.com/showthread.php?t=76358
-
Just guessing but shouldn't it be something like cat.Create("Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & (database) & ";Jet OLEDB:Engine Type=5") note the extra semi-colon after the filename.
-
Yes but Process.Start is the .Net way of doing things, Shell is a legacy vb6 function. Process.Start gives you far more control over running a process - including redirecting input / output to streams, which is what you are after.
-
Recovering quantity of records in a table
PlausiblyDamp replied to see07's topic in Database / XML / Reporting
Try TextBox2.Text=comandante.ExecuteScalar().ToString(); -
How to creat exe file from my application on runtime
PlausiblyDamp replied to SuperNeo's topic in General
If you want to create code on the fly then you need to be looking at the classes under System.Reflection.Emit - these are the ones that allow you to construct assemblies dynamically. What kind of program would A be generating? What are the parameters that determine how this works? -
What is this.MyEvent? Could you show where this is declared. If it is a delegate is it assigned anything? Normally when invoking an event handler you need to check if it points to anything. if (myEvent != null){ this.myEvent(this, e);}
-
Get database connection string from a xml file
PlausiblyDamp replied to dhj's topic in Database / XML / Reporting
Rather than using a COM dll for XML manipulation you could use the built in framework support. A simple example of how to store user settings could be done like this: Create a class to hold your settings Public Class Settings Public connectopnString As String = "FSDFSDFSDFF" 'add other properties if need be End Class to write to it use Dim s As New Settings Dim x As New Xml.Serialization.XmlSerializer(s.GetType) Dim fs As System.IO.FileStream = System.IO.File.OpenWrite("c:\test.xml") x.Serialize(fs, s) fs.Close() and to read a value back Dim s As New Settings Dim x As New Xml.Serialization.XmlSerializer(s.GetType) Dim fs As System.IO.FileStream = System.IO.File.OpenRead("c:\test.xml") s = DirectCast(x.Deserialize(fs), Settings) fs.Close() MessageBox.Show(s.connectopnString) -
Is the folder c:\intepub\wwwroot\webApp1 marked as a virtual directory within IIS?
-
In the mouse click (or mouse up event) you could call the contextmenu's Show method directly (passing the picturebox control as the first parameter). Just out of curiosity why do you want a context menu to appear on a left click as this is fairly non-standard behaviour?
-
Try this version of your original code, It should encrypt and decrypt correctly. It also Base64 encodes the encrypted string making it easier to store safely in a text file or similar. Imports System Imports System.IO Imports System.Text Imports System.Security.Cryptography Namespace encryption Class Crypt Shared key() As Byte = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1} Shared IV() As Byte = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1} Public Shared Function Encrypt(ByVal sdata As String) As String Dim roundtrip As String Dim textConverter As New ASCIIEncoding Dim myRijndael As New RijndaelManaged Dim fromEncrypt() As Byte Dim encrypted() As Byte Dim toEncrypt() As Byte 'set the key and IV. myRijndael.Key = key myRijndael.IV = IV 'Get an encryptor. Dim encryptor As ICryptoTransform = myRijndael.CreateEncryptor(key, IV) 'Encrypt the data. Dim msEncrypt As New MemoryStream Dim csEncrypt As New CryptoStream(msEncrypt, encryptor, CryptoStreamMode.Write) 'Convert the data to a byte array. toEncrypt = textConverter.GetBytes(sdata) 'Write all data to the crypto stream and flush it. csEncrypt.Write(toEncrypt, 0, toEncrypt.Length) csEncrypt.FlushFinalBlock() 'Get encrypted array of bytes. encrypted = msEncrypt.ToArray() Return Convert.ToBase64String(encrypted) End Function Public Shared Function Decrypt(ByVal sdata As String) As String Dim roundtrip As String Dim textConverter As New ASCIIEncoding Dim myRijndael As New RijndaelManaged Dim fromEncrypt() As Byte Dim toEncrypt() As Byte 'Create a new key and initialization vector. myRijndael.GenerateKey() myRijndael.GenerateIV() 'This is where the message would be transmitted to a recipient ' who already knows your secret key. Optionally, you can ' also encrypt your secret key using a public key algorithm ' and pass it to the mesage recipient along with the RijnDael ' encrypted message. 'Get a decryptor that uses the same key and IV as the encryptor. Dim decryptor As ICryptoTransform = myRijndael.CreateDecryptor(key, IV) 'Now decrypt the previously encrypted message using the decryptor ' obtained in the above step. Dim b() As Byte b = Convert.FromBase64CharArray(sdata.ToCharArray, 0, sdata.Length) Dim msDecrypt As New MemoryStream(b) Dim csDecrypt As New CryptoStream(msDecrypt, decryptor, CryptoStreamMode.Read) fromEncrypt = New Byte(sdata.Length) {} 'Read the data out of the crypto stream. csDecrypt.Read(fromEncrypt, 0, fromEncrypt.Length - 1) 'Convert the byte array back into a string. roundtrip = textConverter.GetString(fromEncrypt) Return roundtrip End Function Public Shared Sub main() Dim bExit As Boolean = False Dim sData As String Dim sOut As String Console.WriteLine("########################") Console.WriteLine("#EnCrypter V1.1 #") Console.WriteLine("########################") Do While bExit = False sData = Console.ReadLine() If sData.ToLower.StartsWith("encrypt") Then sData = sData.Substring(8) sData = Encrypt(sData) Console.WriteLine(sData) ElseIf sData.ToLower.StartsWith("decrypt") Then sData = sData.Substring(8) sOut = Decrypt(sData) Console.Write(Decrypt(sData)) ElseIf sData.ToLower.StartsWith("exit") Then bExit = True End If Loop End End Sub End Class End Namespace I would recomend against using the XOR based method above as it is a simple method to crack and it also uses the legacy VB6 file handling functions. If you wanted to make your code more secure you could store the key / iv in a per user config file (possibly requesting a password on a 1st run and storing a key based on their input) - be aware though if they lost the key / config file it would leave them unable to decrypt any of the files.
-
What is the contents of the string that the line ini3.Readstring(Listbox1.SelectedItem, "Icon") returns?
-
You could just hard code some values - the example below isn't exactly the best choice of values ;) Dim key() As Byte = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1} Dim IV() As Byte = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1} 'set the key and IV. myRijndael.Key = key myRijndael.IV = IV