Jump to content
Xtreme .Net Talk

Mr60s

Members
  • Posts

    16
  • Joined

  • Last visited

Everything posted by Mr60s

  1. Hi ! I am trying to log into my website via my vb.net application. The html code i am using on my site is very simple: <form method="POST" action="check.php"> Username: <input name="username" type="text" size="20" value=""> Password: <input name="password" type="password" size="20" value=""> <input type="submit" value="Login"></form> When the information is posted, check.php redirects you to 'good.html' if the username & password is valid. I am trying to get my application to login to the website and download the html source from 'good.html'. To download the source from websites I usually use this code: Dim sr As IO.StreamReader Dim wc As New Net.WebClient() sr = New IO.StreamReader(wc.OpenRead("http://localhost/index.html")) Dim s As String s = sr.ReadToEnd sr.DiscardBufferedData() sr.Close() wc.Dispose() txtInfo.Text = s However i have no idea how to post the login information, can anybody please give me some clues on how to do it? Thanks!
  2. Hi there, I don't really understand what your trying to do, but you could try something like this: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim MyLines As New ArrayList() Dim Total As Integer Dim Random As Integer Dim sreader As New IO.StreamReader("C:/quotes.txt") While Not sreader.Peek MyLines.Add(sreader.ReadLine) End While sreader.Close() Total = MyLines.Count Random = New System.Random().Next(0, Total) TextBox1.Text = MyLines(Random) MyLines.Clear() End Sub
  3. Hello there, Am having a problem adding some controls to a newly created tabpage. I really have no idea what am doing wrong. If I call this code from a click event it works just fine, however when I try calling it from some "other event", all i get to show-up is the tabpage without any controls on it. Am very thankful for any solution or ideas, so they all are welcomed. Public Sub AddTestControl(ByVal Name As String) Dim NewTabPage As New TabPage() 'The new TapPage Dim NewRichText As New RichTextBox() 'The new RichTextBox Dim NewTextBox As New TextBox() 'The new TextBox Dim NewListBox As New ListBox() 'The new ListBox '/// Our new controls setup. '******* RichTextBox ******* NewRichText.Anchor = (((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _ Or System.Windows.Forms.AnchorStyles.Left) _ Or System.Windows.Forms.AnchorStyles.Right) NewRichText.BackColor = System.Drawing.Color.Black NewRichText.Font = New System.Drawing.Font("Courier New", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) NewRichText.ForeColor = System.Drawing.Color.White NewRichText.Location = New System.Drawing.Point(3, 2) NewRichText.Name = Name 'Our uniq name for the Box NewRichText.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.ForcedVertical NewRichText.Size = New System.Drawing.Size(76, 76) '******* TextBox ******* NewTextBox.Anchor = ((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left) _ Or System.Windows.Forms.AnchorStyles.Right) NewTextBox.BackColor = System.Drawing.Color.FromArgb(CType(64, Byte), CType(64, Byte), CType(64, Byte)) NewTextBox.Font = New System.Drawing.Font("Arial", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) NewTextBox.ForeColor = System.Drawing.Color.Silver NewTextBox.Location = New System.Drawing.Point(3, 78) NewTextBox.Name = "Input" & Name 'Our uniq name for the Box NewTextBox.Size = New System.Drawing.Size(200, 21) '******* ListBox ******* NewListBox.Anchor = ((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _ Or System.Windows.Forms.AnchorStyles.Right) NewListBox.BackColor = System.Drawing.Color.FromArgb(CType(64, Byte), CType(0, Byte), CType(0, Byte)) NewListBox.Font = New System.Drawing.Font("Courier New", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) NewListBox.ForeColor = System.Drawing.Color.CornflowerBlue NewListBox.ItemHeight = 14 NewListBox.Location = New System.Drawing.Point(80, 2) NewListBox.Name = "lst" & Name 'Our uniq name for the Box NewListBox.Size = New System.Drawing.Size(120, 78) NewListBox.Sorted = True '/// End control setup. 'Adding the controls to our new tabpage NewTabPage.Text = "Box " & Name 'Giveing our new tabpage a name. NewTabPage.Controls.Add(NewTextBox) NewTabPage.Controls.Add(NewListBox) NewTabPage.Controls.Add(NewRichText) tabControl.Controls.Add(NewTabPage) 'Giveing our new page birth. End Sub
  4. Hi Am trying to determen my current line position in a ritch text box. What I want to do is print the line number am currently typing on to a label. Lets say am typing on line 8, and am moveing up a few lines, to line 2, then I want the label to show "Line: 2", and so on. However I found this harder then I thought it would be, so if anyone can point me in the right direction I would be most grateful. .:. Nevermind I found a way around the problem. <System.Runtime.InteropServices.DllImport("user32")> Shared Function _ SendMessage(ByVal hWnd As Integer, ByVal wMsg As Integer, _ ByVal wParam As Integer, ByVal lParam As Integer) As Integer End Function Function GetTextBoxCurrentLine(ByVal tb As RichTextBox) As Integer Const EM_LINEFROMCHAR As Integer = &HC9 Return SendMessage(tb.Handle.ToInt32(), EM_LINEFROMCHAR, -1, 0) + 1 End Function
  5. I can't believe it, every time I post for help I come up whit an answer. :) Anyways i got it to work like this: Dim i As Integer For i = 0 To 90 Dim Tab As New TabPage("Tab" & i) Dim Rich As New RichTextBox() Rich.Location = New System.Drawing.Point(-1, 0) Rich.Size = New System.Drawing.Size(658, 176) tbMain.Controls.Add(Tab) Tab.Controls.Add(Rich) Next i
  6. Hi, Am trying to add a richtextbox to every tab page as they are added, but am all out of ideas now. Any help would be nice. Thanks! 'This only adds tabs not boxes. Dim i As Integer Dim Tab As New TabPage() Dim Rich As New RichTextBox() Rich.Location = New System.Drawing.Point(-1, 0) Rich.Size = New System.Drawing.Size(658, 176) For i = 0 To 9 Tab.Text = "Tab" & i tbMain.Controls.Add(Tab) Tab.Controls.Add(Rich) Next i
  7. I found an example on Mentalis.org that reads the process memory, however I have been trying to convert this to VB.net without any success, and I was hoping for some help. Private Const PROCESS_ALL_ACCESS As Long = &H1F0FFF Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hWnd As Long, lpdwProcessId As Long) As Long Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long Private Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As Long, ByVal lpBaseAddress As Any, lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long Private Declare Function WriteString Lib "kernel32" Alias "WriteProcessMemory" (ByVal hProcess As Long, ByVal lpBaseAddress As Any, ByVal lpBuffer As Any, ByVal nSize As Long, ByVal lpNumberOfBytesWritten As Long) As Long Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long 'Private Declare Function WriteValue Lib "kernel32" Alias "WriteProcessMemory" (ByVal hProcess As Long, ByVal lpBaseAddress As Any, lpBuffer As Any, ByVal nSize As Long, ByVal lpNumberOfBytesWritten As Long) As Long Private Sub Command1_Click() Dim str As String, MyString As String MyString = "HELLO" 'in this case I read the memory of my own process MsgBox "MyString= " & MyString str = ReadMemory(Me.hWnd, StrPtr(MyString), LenB(MyString), "BYE!!") MsgBox "Now, MyString=" & MyString & vbCr & "Old Value= " & str End Sub Private Function ReadMemory(hWnd As Long, Address As Long, Bytes As Long, Optional strReplaceWith As String) As String 'Runs For Not Unicode Strings (VB-Strings) On Error Resume Next Dim pId As Long ' Used to hold the Process Id Dim pHandle As Long ' Holds the Process Handle Dim bytValue As Long 'Stores the value of a byte in the memory Dim i As Long Dim Text As String ' Get the ProcId of the Window GetWindowThreadProcessId hWnd, pId ' use the pId to get a handle pHandle = OpenProcess(PROCESS_ALL_ACCESS, False, pId) If (pHandle = 0) Then 'MsgBox "Unable to open process!" Exit Function End If If Address = 0 Then Exit Function For i = 1 To Bytes Step 2 ' Read Byte to Byte ReadProcessMemory pHandle, Address + i - 1, bytValue, 1, 0& 'value now contains the long value of the byte located in [Address + i - 1] pos. 'ReadMemory is a string... ReadMemory = ReadMemory & Chr$(bytValue) Next 'to write numeric values you can ..(Must) use WriteValue API If LenB(strReplaceWith) <> 0 Then 'No Unicode!! WriteString pHandle, Address, StrPtr(strReplaceWith), LenB(strReplaceWith), 0& End If 'Close the Handle CloseHandle pHandle End Function
  8. Hi ! What am trying to do is read another process memory. I know i can use the API ReadProcessMemory, OpenProcess and CloseHandle. But i have no idea on how to declare those API's. Can anyone help me on this problem?
  9. Works great, thanks for the fast reply.
  10. Hi ! Am having problem's finding my current position in a rich text box. By position i mean the position where i am typing. Any ideas on how to find it?
  11. Never mind i found another way around my problem. Private Sub Console_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Console.TextChanged Console.SelectionStart = Len(Console.Text) Console.Focus() InputLine.Focus() End Sub This will scroll the RTP to the end.
  12. Hi ! I found this code example in the FAQ at top of this forum, but i got this problem. Can anyone help me make it, so i can use it in VB.net? Thanks allot. const int SB_VERT = 1; const int EM_SETSCROLLPOS = 0x0400 + 222; [DllImport("user32", CharSet=CharSet.Auto)] public static extern bool GetScrollRange(IntPtr hWnd, int nBar, out int lpMinPos, out int lpMaxPos); [DllImport("user32", CharSet=CharSet.Auto)] public static extern IntPtr SendMessage(IntPtr hWnd, int msg, int wParam, POINT lParam); [structLayout(LayoutKind.Sequential)] public class POINT { public int x; public int y; public POINT() { } public POINT(int x, int y) { this.x = x; this.y = y; } } // Example -- scroll the RTB so the bottom of the text is always visible. int min, max; GetScrollRange(richTextBox1.Handle, SB_VERT, out min, out max); SendMessage(richTextBox1.Handle, EM_SETSCROLLPOS, 0, new POINT(0, max - richTextBox1.Height));
  13. Hi ! I got this problem and was hoping for some help. I got this text-box and a button on my form. And i have notepad open, but minimized. What i want to do is: when i click the button i want the text in the text-box to be printed to the minimized notepad. If it's possible of course. Some sample code would help allot. Thanks!
  14. nevermind i found it, thanks for the help.
  15. Can you tell me where and on what cd? I got 6 visual studio cds.
  16. Hi ! I just got .net like a month ago, am trying to learn vb.net and i have this problem. I got this book about it but it dont take up how to compile your program for other windows platforms that dont have a version of VB installed. It only takes up the "build" "release" thing, but it says that to run it on a computer that dont have VB installed you need to compile it whit dll's and . Lets say i make this windows fourm in vb.net and i want to compile it for use on a computer that dont have VB installed. Can someone explain step by step how to do it, and how it works? Thanks for the help!
×
×
  • Create New...