Click here to Skip to main content
15,907,329 members
Home / Discussions / C#
   

C#

 
GeneralRe: VB6 (eek!) to VB.net to C#????? Pin
Christian Graus20-Jul-05 14:56
protectorChristian Graus20-Jul-05 14:56 
GeneralRe: VB6 (eek!) to VB.net to C#????? Pin
WetRivrRat20-Jul-05 15:15
WetRivrRat20-Jul-05 15:15 
GeneralRe: VB6 (eek!) to VB.net to C#????? Pin
tatchung20-Jul-05 15:42
tatchung20-Jul-05 15:42 
GeneralRe: VB6 (eek!) to VB.net to C#????? Pin
Christian Graus20-Jul-05 15:49
protectorChristian Graus20-Jul-05 15:49 
GeneralRe: VB6 (eek!) to VB.net to C#????? Pin
Christian Graus20-Jul-05 15:53
protectorChristian Graus20-Jul-05 15:53 
GeneralRe: VB6 (eek!) to VB.net to C#????? Pin
WetRivrRat20-Jul-05 17:25
WetRivrRat20-Jul-05 17:25 
GeneralRe: VB6 (eek!) to VB.net to C#????? Pin
Christian Graus20-Jul-05 17:38
protectorChristian Graus20-Jul-05 17:38 
GeneralRe: VB6 (eek!) to VB.net to C#????? Pin
WetRivrRat20-Jul-05 17:42
WetRivrRat20-Jul-05 17:42 
David, thanks for the direction to the app, here are the results for the project as a whole, enclosed are the results and the corresonding code.
I purposely did not omit anyting... sorry its so long...
I have higlighted the lines that are erroring.... I am currently working on debuggin this, but any assistance will be greatly apreciated!!!
remember this WAS working in vb after conversion from vb6 to vb.net.

1.\Form1.cs(269): No overload for method 'FileOpen' takes '3' arguments
2.\Form1.cs(270): The best overloaded method match for 'string.PadLeft(int)' has some invalid arguments
3.\Form1.cs(270): Argument '1': cannot convert from 'long' to 'int'
4.\Form1.cs(272): The best overloaded method match for 'Microsoft.VisualBasic.FileSystem.FileGet(int, ref System.ValueType, long)' has some invalid arguments
5.\Form1.cs(272): Argument '2': cannot convert from 'string' to 'ref System.ValueType'
6.\Form1.cs(293): No overload for method 'FileOpen' takes '3' arguments
7.\Form1.cs(331): Cannot implicitly convert type 'int' to 'short'
8.\Form1.cs(332): Cannot implicitly convert type 'int' to 'short'


//INSTANT C# NOTE: Formerly VB.NET project-level imports:
using Microsoft.VisualBasic.Compatibility.VB6;
using System;
using System.Collections;
using System.Data;
using System.Drawing;
using System.Diagnostics;
using System.Windows.Forms;
namespace Project1
{
	internal class Form1 : System.Windows.Forms.Form
	{
	#region Windows Form Designer generated code 
		public Form1() : base()
		{
			if (m_vb6FormDefInstance == null)
			{
				if (m_InitializingDefInstance)
				{
					m_vb6FormDefInstance = this;
				}
				else
				{
					try
					{
						//For the start-up form, the first instance created is the default instance.
						if (System.Reflection.Assembly.GetExecutingAssembly().EntryPoint.DeclaringType == this.GetType())
						{
							m_vb6FormDefInstance = this;
						}
					}
					catch
					{
					}
				}
			}
			//This call is required by the Windows Form Designer.
			InitializeComponent();

		}
		//Form overrides dispose to clean up the component list.
		protected override void Dispose(bool Disposing)
		{
			if (Disposing)
			{
				if (components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose(Disposing);
		}
		//Required by the Windows Form Designer
		private System.ComponentModel.IContainer components;
		public System.Windows.Forms.ToolTip ToolTip1;
		public System.Windows.Forms.Button cmdDecrypt;
		public System.Windows.Forms.TextBox txtPath;
		public System.Windows.Forms.TextBox txtSalt;
		public System.Windows.Forms.TextBox txtText;
		public System.Windows.Forms.Button cmdEncrypt;
		public System.Windows.Forms.Label Label2;
		public System.Windows.Forms.Label Label1;
		//NOTE: The following procedure is required by the Windows Form Designer
		//It can be modified using the Windows Form Designer.
		//Do not modify it using the code editor.
		[System.Diagnostics.DebuggerStepThrough()]
		private void InitializeComponent()
		{
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
			this.components = new System.ComponentModel.Container();
			this.ToolTip1 = new System.Windows.Forms.ToolTip(components);
			this.ToolTip1.Active = true;
			this.cmdDecrypt = new System.Windows.Forms.Button();
			this.txtPath = new System.Windows.Forms.TextBox();
			this.txtSalt = new System.Windows.Forms.TextBox();
			this.txtText = new System.Windows.Forms.TextBox();
			this.cmdEncrypt = new System.Windows.Forms.Button();
			this.Label2 = new System.Windows.Forms.Label();
			this.Label1 = new System.Windows.Forms.Label();
			this.Text = "Form1";
			this.ClientSize = new System.Drawing.Size(312, 213);
			this.Location = new System.Drawing.Point(4, 23);
			this.StartPosition = System.Windows.Forms.FormStartPosition.WindowsDefaultLocation;
			this.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, System.Convert.ToByte(0));
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.BackColor = System.Drawing.SystemColors.Control;
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Sizable;
			this.ControlBox = true;
			this.Enabled = true;
			this.KeyPreview = false;
			this.MaximizeBox = true;
			this.MinimizeBox = true;
			this.Cursor = System.Windows.Forms.Cursors.Default;
			this.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.ShowInTaskbar = true;
			this.HelpButton = false;
			this.WindowState = System.Windows.Forms.FormWindowState.Normal;
			this.Name = "Form1";
			this.cmdDecrypt.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			this.cmdDecrypt.Text = "Decrypt";
			this.cmdDecrypt.Size = new System.Drawing.Size(97, 33);
			this.cmdDecrypt.Location = new System.Drawing.Point(112, 128);
			this.cmdDecrypt.TabIndex = 6;
			this.cmdDecrypt.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, System.Convert.ToByte(0));
			this.cmdDecrypt.BackColor = System.Drawing.SystemColors.Control;
			this.cmdDecrypt.CausesValidation = true;
			this.cmdDecrypt.Enabled = true;
			this.cmdDecrypt.ForeColor = System.Drawing.SystemColors.ControlText;
			this.cmdDecrypt.Cursor = System.Windows.Forms.Cursors.Default;
			this.cmdDecrypt.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.cmdDecrypt.TabStop = true;
			this.cmdDecrypt.Name = "cmdDecrypt";
			this.txtPath.AutoSize = false;
			this.txtPath.Size = new System.Drawing.Size(265, 25);
			this.txtPath.Location = new System.Drawing.Point(8, 96);
			this.txtPath.TabIndex = 5;
			this.txtPath.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, System.Convert.ToByte(0));
			this.txtPath.AcceptsReturn = true;
			this.txtPath.TextAlign = System.Windows.Forms.HorizontalAlignment.Left;
			this.txtPath.BackColor = System.Drawing.SystemColors.Window;
			this.txtPath.CausesValidation = true;
			this.txtPath.Enabled = true;
			this.txtPath.ForeColor = System.Drawing.SystemColors.WindowText;
			this.txtPath.HideSelection = true;
			this.txtPath.ReadOnly = false;
			this.txtPath.MaxLength = 0;
			this.txtPath.Cursor = System.Windows.Forms.Cursors.IBeam;
			this.txtPath.Multiline = false;
			this.txtPath.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.txtPath.ScrollBars = System.Windows.Forms.ScrollBars.None;
			this.txtPath.TabStop = true;
			this.txtPath.Visible = true;
			this.txtPath.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
			this.txtPath.Name = "txtPath";
			this.txtSalt.AutoSize = false;
			this.txtSalt.Size = new System.Drawing.Size(137, 25);
			this.txtSalt.Location = new System.Drawing.Point(8, 56);
			this.txtSalt.TabIndex = 2;
			this.txtSalt.Text = "WetRi";
			this.txtSalt.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, System.Convert.ToByte(0));
			this.txtSalt.AcceptsReturn = true;
			this.txtSalt.TextAlign = System.Windows.Forms.HorizontalAlignment.Left;
			this.txtSalt.BackColor = System.Drawing.SystemColors.Window;
			this.txtSalt.CausesValidation = true;
			this.txtSalt.Enabled = true;
			this.txtSalt.ForeColor = System.Drawing.SystemColors.WindowText;
			this.txtSalt.HideSelection = true;
			this.txtSalt.ReadOnly = false;
			this.txtSalt.MaxLength = 0;
			this.txtSalt.Cursor = System.Windows.Forms.Cursors.IBeam;
			this.txtSalt.Multiline = false;
			this.txtSalt.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.txtSalt.ScrollBars = System.Windows.Forms.ScrollBars.None;
			this.txtSalt.TabStop = true;
			this.txtSalt.Visible = true;
			this.txtSalt.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
			this.txtSalt.Name = "txtSalt";
			this.txtText.AutoSize = false;
			this.txtText.Size = new System.Drawing.Size(137, 25);
			this.txtText.Location = new System.Drawing.Point(8, 16);
			this.txtText.TabIndex = 1;
			this.txtText.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, System.Convert.ToByte(0));
			this.txtText.AcceptsReturn = true;
			this.txtText.TextAlign = System.Windows.Forms.HorizontalAlignment.Left;
			this.txtText.BackColor = System.Drawing.SystemColors.Window;
			this.txtText.CausesValidation = true;
			this.txtText.Enabled = true;
			this.txtText.ForeColor = System.Drawing.SystemColors.WindowText;
			this.txtText.HideSelection = true;
			this.txtText.ReadOnly = false;
			this.txtText.MaxLength = 0;
			this.txtText.Cursor = System.Windows.Forms.Cursors.IBeam;
			this.txtText.Multiline = false;
			this.txtText.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.txtText.ScrollBars = System.Windows.Forms.ScrollBars.None;
			this.txtText.TabStop = true;
			this.txtText.Visible = true;
			this.txtText.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
			this.txtText.Name = "txtText";
			this.cmdEncrypt.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			this.cmdEncrypt.Text = "Encrypt and Save";
			this.cmdEncrypt.Size = new System.Drawing.Size(97, 33);
			this.cmdEncrypt.Location = new System.Drawing.Point(8, 128);
			this.cmdEncrypt.TabIndex = 0;
			this.cmdEncrypt.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, System.Convert.ToByte(0));
			this.cmdEncrypt.BackColor = System.Drawing.SystemColors.Control;
			this.cmdEncrypt.CausesValidation = true;
			this.cmdEncrypt.Enabled = true;
			this.cmdEncrypt.ForeColor = System.Drawing.SystemColors.ControlText;
			this.cmdEncrypt.Cursor = System.Windows.Forms.Cursors.Default;
			this.cmdEncrypt.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.cmdEncrypt.TabStop = true;
			this.cmdEncrypt.Name = "cmdEncrypt";
			this.Label2.Text = "Salt";
			this.Label2.Size = new System.Drawing.Size(105, 25);
			this.Label2.Location = new System.Drawing.Point(152, 56);
			this.Label2.TabIndex = 4;
			this.Label2.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, System.Convert.ToByte(0));
			this.Label2.TextAlign = System.Drawing.ContentAlignment.TopLeft;
			this.Label2.BackColor = System.Drawing.SystemColors.Control;
			this.Label2.Enabled = true;
			this.Label2.ForeColor = System.Drawing.SystemColors.ControlText;
			this.Label2.Cursor = System.Windows.Forms.Cursors.Default;
			this.Label2.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.Label2.UseMnemonic = true;
			this.Label2.Visible = true;
			this.Label2.AutoSize = false;
			this.Label2.BorderStyle = System.Windows.Forms.BorderStyle.None;
			this.Label2.Name = "Label2";
			this.Label1.Text = "Date";
			this.Label1.Size = new System.Drawing.Size(97, 25);
			this.Label1.Location = new System.Drawing.Point(152, 16);
			this.Label1.TabIndex = 3;
			this.Label1.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, System.Convert.ToByte(0));
			this.Label1.TextAlign = System.Drawing.ContentAlignment.TopLeft;
			this.Label1.BackColor = System.Drawing.SystemColors.Control;
			this.Label1.Enabled = true;
			this.Label1.ForeColor = System.Drawing.SystemColors.ControlText;
			this.Label1.Cursor = System.Windows.Forms.Cursors.Default;
			this.Label1.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.Label1.UseMnemonic = true;
			this.Label1.Visible = true;
			this.Label1.AutoSize = false;
			this.Label1.BorderStyle = System.Windows.Forms.BorderStyle.None;
			this.Label1.Name = "Label1";
			this.Controls.Add(cmdDecrypt);
			this.Controls.Add(txtPath);
			this.Controls.Add(txtSalt);
			this.Controls.Add(txtText);
			this.Controls.Add(cmdEncrypt);
			this.Controls.Add(Label2);
			this.Controls.Add(Label1);
			//INSTANT C# NOTE: Converted event handlers:
			cmdDecrypt.Click += new System.EventHandler(cmdDecrypt_Click);
			cmdEncrypt.Click += new System.EventHandler(cmdEncrypt_Click);
			base.Load += new System.EventHandler(Form1_Load);

		}
	#endregion
	#region Upgrade Support 
		private static Form1 m_vb6FormDefInstance;
		private static bool m_InitializingDefInstance;
		public static Form1 DefInstance
		{
			get
			{
				if (m_vb6FormDefInstance == null || m_vb6FormDefInstance.IsDisposed)
				{
					m_InitializingDefInstance = true;
					m_vb6FormDefInstance = new Form1();
					m_InitializingDefInstance = false;
				}
				return m_vb6FormDefInstance;
			}
			set
			{
				m_vb6FormDefInstance = value;
			}
		}
	#endregion
		private void cmdDecrypt_Click(object eventSender, System.EventArgs eventArgs)
		{

			string Saved = null;

			//UPGRADE_WARNING: Dir has a new behavior. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1041"'
			if (Microsoft.VisualBasic.FileSystem.Dir(txtPath.Text, Microsoft.VisualBasic.FileAttribute.Normal).Length > 0)
			{
				Microsoft.VisualBasic.FileSystem.FileOpen(1, txtPath.Text, Microsoft.VisualBasic.OpenMode.Binary);
				Saved = string.Empty.PadLeft(Microsoft.VisualBasic.FileSystem.LOF(1));
				//UPGRADE_WARNING: Get was upgraded to FileGet and has a new behavior. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1041"'
				Microsoft.VisualBasic.FileSystem.FileGet(1, Saved, 1);				Microsoft.VisualBasic.FileSystem.FileClose(1);
				System.Diagnostics.Debug.WriteLine(Crypt(Saved, txtSalt.Text));
				MessageBox.Show(Crypt(Saved, txtSalt.Text));
			}
			else
			{
				MessageBox.Show(txtPath.Text + " not found!");
				return;
			}


		}

		private void cmdEncrypt_Click(object eventSender, System.EventArgs eventArgs)
		{
			//UPGRADE_WARNING: Dir has a new behavior. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1041"'
			if (Microsoft.VisualBasic.FileSystem.Dir(txtPath.Text, Microsoft.VisualBasic.FileAttribute.Normal).Length > 0)
			{
				Microsoft.VisualBasic.FileSystem.Kill(txtPath.Text);
			}
			Microsoft.VisualBasic.FileSystem.FileOpen(1, txtPath.Text, Microsoft.VisualBasic.OpenMode.Binary);
			//UPGRADE_WARNING: Put was upgraded to FilePut and has a new behavior. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1041"'
			Microsoft.VisualBasic.FileSystem.FilePut(1, Crypt(txtText.Text, txtSalt.Text), -1);
			Microsoft.VisualBasic.FileSystem.FileClose(1);
			MessageBox.Show("Saved!");
		}

		private void Command1_Click()
		{

			string TT = null;
			string Salt = null;

			TT = "this is the one I love and hate";
			Salt = "WetRivrRat";

			string Encrypted = null;
			Encrypted = Crypt(TT, Salt);

			System.Diagnostics.Debug.WriteLine(Encrypted);

			System.Diagnostics.Debug.WriteLine(Crypt(Encrypted, Salt));

		}

		//UPGRADE_NOTE: Text was upgraded to Text_Renamed. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1061"'
		private string Crypt(string Text_Renamed, string Key)
		{
			int KeyLen = 0;
				int i = 0;
					int KeyPtr = 0;
			short KeyChr = 0;
				short TextChr = 0;
			KeyLen = Key.Length;
//INSTANT C# NOTE: The ending condition of VB 'For' loops is tested only on entry to the loop. Instant C# has created a temporary variable in order to use the initial value of Len(Text_Renamed) for every iteration:
			int tempFor1 = Text_Renamed.Length;
			for (i = 1; i <= tempFor1; i++)
			{
				TextChr = System.Convert.ToInt32(Text_Renamed[0]);
				KeyChr = System.Convert.ToInt32(Key[0]);
				Text_Renamed = Text_Renamed.Remove(i - 1, 1).Insert(i - 1, ((char)(TextChr ^ KeyChr)).ToString());
				KeyPtr = ((KeyPtr + 1) % KeyLen);
			}
			return Text_Renamed;
		}

		private void Form1_Load(object eventSender, System.EventArgs eventArgs)
		{
			txtText.Text = System.Convert.ToString(System.DateTime.Now);
			txtPath.Text = Support.GetPath() + "\\DateTest.bin";
		}

		[STAThread]
		static void Main()
		{
			Application.Run(new Form1());
		}

	}
} //end of root namespace


Dim Beautiful As String
Beautiful = "ignorant"
Label1.Text = "The world is full of " & Beautiful & " people."


Why is common sense such an un-common comodity?
GeneralRe: VB6 (eek!) to VB.net to C#????? Pin
Christian Graus20-Jul-05 17:47
protectorChristian Graus20-Jul-05 17:47 
GeneralRe: VB6 (eek!) to VB.net to C#????? Pin
WetRivrRat20-Jul-05 18:01
WetRivrRat20-Jul-05 18:01 
GeneralRe: VB6 (eek!) to VB.net to C#????? Pin
Christian Graus20-Jul-05 18:09
protectorChristian Graus20-Jul-05 18:09 
AnswerRe: VB6 (eek!) to VB.net to C#????? Pin
Dave Doknjas20-Jul-05 16:13
Dave Doknjas20-Jul-05 16:13 
GeneralRe: VB6 (eek!) to VB.net to C#????? Pin
Christian Graus20-Jul-05 17:41
protectorChristian Graus20-Jul-05 17:41 
GeneralRe: VB6 (eek!) to VB.net to C#????? Pin
Dave Doknjas20-Jul-05 19:24
Dave Doknjas20-Jul-05 19:24 
GeneralRe: VB6 (eek!) to VB.net to C#????? Pin
Christian Graus21-Jul-05 13:20
protectorChristian Graus21-Jul-05 13:20 
GeneralPrinting window form Pin
quangmogulasia20-Jul-05 12:57
quangmogulasia20-Jul-05 12:57 
GeneralFocus Pin
nc3b20-Jul-05 12:39
nc3b20-Jul-05 12:39 
GeneralRe: Focus Pin
Mark Greenwood20-Jul-05 18:07
Mark Greenwood20-Jul-05 18:07 
GeneralRe: Focus Pin
nc3b21-Jul-05 0:01
nc3b21-Jul-05 0:01 
GeneralRe: Focus Pin
nc3b21-Jul-05 1:15
nc3b21-Jul-05 1:15 
GeneralRe: Focus Pin
[Marc]21-Jul-05 16:10
[Marc]21-Jul-05 16:10 
GeneralRe: Focus Pin
nc3b21-Jul-05 21:21
nc3b21-Jul-05 21:21 
GeneralRe: Focus Pin
[Marc]22-Jul-05 9:29
[Marc]22-Jul-05 9:29 
QuestionHow can i find the DataRow number in DataRowCollection Pin
m.rastgar20-Jul-05 12:30
m.rastgar20-Jul-05 12:30 
GeneralTransparent Overlapping Panels Problem... Pin
rcurrie20-Jul-05 12:25
rcurrie20-Jul-05 12:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.