|
Hello Friends,
Is it Possible in Windows Application To Upload a File to a Remote Server.Please Help soon If Possible.
hiiiiii
|
|
|
|
|
Of course. But, everything dpends on what type of server you're uploading to, ...which you didn't say anything about.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi,
I wonder if someone has the knowledge I lack, I am trying to resolve a hostname through a proxy server in vb.net but I am figure out how to combine these subroutines?
This sub is to give a proxy server some credentials and download the html from the page
Warning **** imports system.net at top of code ****
Private Sub Myproxy()
Dim result As String = ""
Try
Dim proxy As WebProxy = New WebProxy("http://proxy:80/", True)
proxy.Credentials = New NetworkCredential("username", "password", "domain.com")
Dim request As WebRequest = WebRequest.Create("http://www.c-sharpcorner.com")
request.Proxy = proxy
Dim response As HttpWebResponse = CType(request.GetResponse, HttpWebResponse)
Dim stream As System.IO.Stream = response.GetResponseStream
Dim ec As System.Text.Encoding = System.Text.Encoding.GetEncoding("utf-8")
Dim reader As System.IO.StreamReader = New System.IO.StreamReader(stream, ec)
Dim chars(256) As Char
Dim count As Integer = reader.Read(chars, 0, 256)
While count > 0
Dim str As String = New String(chars, 0, 256)
result = result + str
count = reader.Read(chars, 0, 256)
End While
RichTextBox1.Text = result
response.Close()
stream.Close()
reader.Close()
Catch exp As Exception
Dim str As String = exp.Message
End Try
End Sub
This is the sub to resolve the hostname
Public Sub DisplayHostAddress(ByVal hostString As [String])
Try
Dim hostInfo As IPHostEntry = Dns.Resolve(hostString)
' Get the IP address list that resolves to the host names contained in the Alias
' property.
Dim address As IPAddress() = hostInfo.AddressList
' Get the alias names of the addresses in the IP address list.
Dim [alias] As [String]() = hostInfo.Aliases
MsgBox(("Host name : " + hostInfo.HostName))
'MsgBox(ControlChars.Cr + "Aliases : ")
Dim index As Integer
For index = 0 To [alias].Length - 1
MsgBox([alias](index))
Next index
'MsgBox(ControlChars.Cr + "IP Address list :")
For index = 0 To address.Length - 1
MsgBox(Convert.ToString(address(index)))
Next index
Catch e As Net.Sockets.SocketException
MsgBox("SocketException caught!!!")
MsgBox(("Source : " + e.Source))
MsgBox(("Message : " + e.Message))
Catch e As ArgumentNullException
MsgBox("ArgumentNullException caught!!!")
MsgBox(("Source : " + e.Source))
MsgBox(("Message : " + e.Message))
Catch e As NullReferenceException
MsgBox("NullReferenceException caught!!!")
MsgBox(("Source : " + e.Source))
MsgBox(("Message : " + e.Message))
Catch e As Exception
MsgBox("Exception caught!!!")
MsgBox(("Source : " + e.Source))
MsgBox(("Message : " + e.Message))
End Try
End Sub
so for example to resolve:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.DisplayHostAddress("http://www.codeproject.com")
End Sub
thanks
|
|
|
|
|
I want my VBScript to stop for 4 seconds before starting again.
Searched the web and found this "WScript.Sleep 4000".
The problem is that when I use this code i get an error "Object required 'WScript'".
What is wrong?
Is there a better way to do this?
Spaz
|
|
|
|
|
It should be:
WScript.Sleep(4000)
If your running your script under CSCRIPT.EXE or WSCRIPT.EXE, nothing else is required.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
hello friends
i need help for using unicode & ASCII code using in vb-6
for language conversion and enabling right-to-left language
conversion code e.g. English to Arabic or induan punjabi
Charactor conversion or designing Arabic & punjabi Controls
or formats
zain
|
|
|
|
|
hi friends
i need help for call .lib & .cab files in visual basic-6 projects
zain
|
|
|
|
|
You don't makes calls into these types of files. A .lib file is something C/C++ gets compiled with and a .cab file is a compressed "cabinet" file, like a .ZIP file.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi !
I need to write a VBScript which would launch a command application (nmake, not to name it) and I'd like that the output produced by nmake being displayed in the command window from where I launched the VB Script.
I did some googling but didn't find anything which works...
Any idea ?
Thanks !
Jerome
|
|
|
|
|
I add a system.data .net reference in project , and use these code in a winform.
imports system.data
Dim theData As DataTable
^^^^^^^^^ ---- Error!
Why?
|
|
|
|
|
Did you add a reference to system.data.dll in the solution explorer?
|
|
|
|
|
I tried to set the printpreviewdialog.showdialog to fullscreen,including set top=0, left=0, width=screen....width,height=screen...height.
However,the top is always not 0 acturally.
Why?
|
|
|
|
|
have you tried to set the windowstate property?
Briga
Dim a As PrintPreviewDialog
Public Sub test()
a.WindowState = FormWindowState.Maximized
End Sub
|
|
|
|
|
I have tried out various code on capturing keypress and doubleclick events on the datagrid. But the problem is when you add the keypress support, the doubleclick won't fire out.
here is the code for trapping double click
Dim grdColStyle1As New DataGridKeyTrapTextBoxColumn
grdColStyle1.MappingName = "Acc_Curr_Balance"
grdColStyle1.HeaderText = "Account Balance"
grdColStyle1.Width = 225
AddHandler grdColStyle1.TextBox.MouseDown, New MouseEventHandler(AddressOf TextBoxMouseDownHandler)
AddHandler grdColStyle1.TextBox.DoubleClick, New EventHandler(AddressOf TextBoxDoubleClickHandler)
Private Sub TextBoxMouseDownHandler(ByVal sender As Object, ByVal e As MouseEventArgs)
If (DateTime.Now < gridMouseDownTime.AddMilliseconds(SystemInformation.DoubleClickTime)) Then
btnOk_Click(sender, e)
End If
End Sub
Private Sub TextBoxDoubleClickHandler(ByVal sender As Object, ByVal e As EventArgs)
Try
btnOk_Click(sender, e)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
' trap the key press
Public Class DataGridKeyTrapTextBoxColumn
Inherits DataGridTextBoxColumn
Private _keyTrapTextBox As KeyTrapTextBox = Nothing
Private _source As System.Windows.Forms.CurrencyManager = Nothing
Private _rowNum As Integer
Private _isEditing As Boolean = False
Public Shared _RowCount As Integer = 0
Private mTxt1 As String
Private mTxt2 As String
Private mTxt3 As String
Private mClicked As Boolean = False
Public Sub New()
_keyTrapTextBox = New KeyTrapTextBox
_keyTrapTextBox.BorderStyle = BorderStyle.None
AddHandler _keyTrapTextBox.Leave, AddressOf LeaveKeyTrapTextBox
AddHandler _keyTrapTextBox.KeyPress, AddressOf TextBoxEditStarted
End Sub 'New
Private Sub TextBoxEditStarted(ByVal sender As Object, ByVal e As KeyPressEventArgs)
_isEditing = True
'dim cm as CurrencyManager =
'If e.KeyChar = Chr(13) Then
' MsgBox(CType(sender, TextBox).Text)
'End If
MyBase.ColumnStartedEditing(CType(sender, Control))
End Sub 'TextBoxEditStarted
Private Sub LeaveKeyTrapTextBox(ByVal sender As Object, ByVal e As EventArgs)
If _isEditing Then
SetColumnValueAtRow(_source, _rowNum, _keyTrapTextBox.Text)
_isEditing = False
Invalidate()
End If
_keyTrapTextBox.Hide()
End Sub 'LeaveKeyTrapTextBox
Protected Overloads Overrides Sub Edit(ByVal [source] As System.Windows.Forms.CurrencyManager, ByVal rowNum As Integer, ByVal bounds As System.Drawing.Rectangle, ByVal [readOnly] As Boolean, ByVal instantText As String, ByVal cellIsVisible As Boolean)
_RowCount = [source].Count
MyBase.Edit([source], rowNum, bounds, [readOnly], instantText, cellIsVisible)
_rowNum = rowNum
_source = [source]
_keyTrapTextBox.Parent = Me.TextBox.Parent
_keyTrapTextBox.Location = Me.TextBox.Location
_keyTrapTextBox.Size = Me.TextBox.Size
_keyTrapTextBox.Text = Me.TextBox.Text
Me.TextBox.Visible = False
_keyTrapTextBox.Visible = True
_keyTrapTextBox.BringToFront()
_keyTrapTextBox.Focus()
'sets the textbox values
End Sub 'Edit
Protected Overrides Function Commit(ByVal dataSource As System.Windows.Forms.CurrencyManager, ByVal rowNum As Integer) As Boolean
If _isEditing Then
_isEditing = False
SetColumnValueAtRow(dataSource, rowNum, _keyTrapTextBox.Text)
End If
Return True
End Function 'Commit
End Class 'DataGridKeyTrapTextBoxColumn
Public Class KeyTrapTextBox
Inherits TextBox
Public Sub New()
Me.ReadOnly = True
End Sub 'New
Private Const WM_KEYDOWN As Integer = &H100
Private Const WM_KEYUP As Integer = &H101
Private Const WM_CHAR As Integer = &H102
Public Overrides Function PreProcessMessage(ByRef msg As Message) As Boolean
Dim keyCode As Keys = CType(msg.WParam.ToInt32(), Keys) And Keys.KeyCode
If msg.Msg = WM_KEYDOWN Then
Console.WriteLine(("TextBox.WM_KEYDOWN key: " + keyCode.ToString()))
End If
' for a datagrid, we need to eat the tab key oe else its done twice
If msg.Msg = WM_KEYDOWN AndAlso keyCode = Keys.Tab Then
'to ignore a message return true without calling baseclass
'to let the textbox handle message return false;
'don't let textbox handle tab
Return True
End If
Return MyBase.PreProcessMessage(msg)
' //sample handling code. This lets the textbox handle the delete
' //& preventing (for example) a delete shortcut on a menu getting it
' if((msg.Msg == WM_KEYDOWN)
' && keyCode == Keys.Delete)
' {
' //to ignore a message return true without calling baseclass
' //to let the textbox handle message return false;
'
' //let textbox handle Delete
' return false;
' }
'Return MyBase.PreProcessMessage(msg)
End Function 'PreProcessMessage
End Class 'KeyTrapTextBox
pls can anybody help me to sort this out?
samitha
|
|
|
|
|
I am using sqlconnection control in vb.net and i use it for different form.
Everytime if i move my database and my application to other Computer, I need to change the connection string one by one in each form and of course this is abit troublesome for me.
Any ways to change the sqlconnection string in properties only 'once', and all sqlconnection string in all forms will also change?
|
|
|
|
|
Hey Buddy you must use app.config file. If you do need an example i will provide you ok. Wait
Bye...
Muhammad Waqas Butt
waqasb4alll@yahoo.com
|
|
|
|
|
I would love to see the example.
Sorry for double posting thread
|
|
|
|
|
Here is Code Buddy...
First add App.config file into your project.
[1] Add below code in the App.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="constr" value="data source=SK-WAQASBUTT;initial catalog=Northwind;user id=waqas;Password=butt" />
</appSettings>
</configuration>
How to get the key value. code is:
First add system.configration; reference is the file. then add this code on you button click.
try
{
string consetting = ConfigurationSettings.AppSettings["constr"]; // Get the Key value from app.config.
// I'm not good in VB.Net but still a try In VB.Net get key value could like this
// String consetting As ConfigurationSettings.AppSettings["constr"]
txtconstr.Text = consetting;
}
catch(Exception ex)
{
MessageBox.Show("Exception : " + ex.Message,
"Muhammad Waqas Butt",
MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
}
See how simple is to do.
Ok please inform me if any problem occure in this code ok
<b>Muhammad Waqas Butt:->
waqasb4all@yahoo.com</b>
|
|
|
|
|
I am using sqlconnection control in vb.net and i use it for different form.
Everytime if i move my database and my application to other Computer, I need to change the connection string one by one in each form and of course this is abit troublesome for me. Any ways to change the sqlconnection string in properties only 'once', and all sqlconnection string in all forms will also change?
|
|
|
|
|
This is a frightening window into how badly designed your application is. This sort of stuff should be stored in a config file.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I did that because every form need adapter if want to connection to sql. When i drag and drop the adapter and and set sql command, a sqlconnection1 will appear.
That's why every form will have sqlconnection1. When i use other pc and copy my application, then i need to change every sqlconnection string in each form. If possible i want to set it once and all sqlconnection1.connectionstring are changed.
|
|
|
|
|
You can't do that using the "Drag and Drop" controls. It's always been better to write your own SQL connection code. You'll have to replace these connection objects with your own code that reads what the connection string should be from a config file.
A better method would be to centralize all your SQL code into a seperate class. Then, each form could use the SQL methods you expose in this class to handle all the data. This is what is meant by the "data tier" in a multiple-tier application.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Damn - you said the same as I did, but a lot more politely. I need some sleep.....
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I was feeling particularly gracious today! It's about 10pm here now, so, that'll end in about 2 hours!
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Welcome to the world of programming. We tend to write code rather than drag stuff onto a pretty designer.
Seriously, the IDE lets you do this, but it's crap. You should have a central class for data access, and ideally a connection object that is reused, or even a pool, depending on the app.
Christian Graus - Microsoft MVP - C++
|
|
|
|