|
break_day wrote: event click without button click ?
What do you mean? Do you want to handle button click in another event handler instead of default handler ?
|
|
|
|
|
i play sound some time and after that i want handle button click (this click load anther form)without the user click the the button
|
|
|
|
|
if this question is as simple as I think you may register a public bool buttonclicked =false
and somewhere in your program logic if you set the value to true, a separate procedure would be called (what would normally be called upon a button click event) sg like:
void buttonclicked()
{
//do something...
}
|
|
|
|
|
If you are not using e or sender in your code you can use
EventName(Nothing, Nothing)
Quote from Great Outdoors:
its a confident traveller who farts in India
|
|
|
|
|
see Button.PerformClick method.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use PRE tags to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Hello there.
I am creating an application that is connected to a phone line via modem.
I then use a paging software, InfoRad, that sends message to my application by dialing the phone number that my application is using.
The problem comes after InfoRad gets connected to my application then garbage data starts coming and InfoRad shows error about Handshake problem.
I am using baud rate, data bit, parity bit, stop bit as given by InfoRad (http://www.inforad.com/remoteerror.html)
In my receiving application I am printing the receiving characters byte by byte and converting it to string for display.
How should I read the receiving data? Any help will be appreciated.
Thanks.
|
|
|
|
|
Since we know nothing about InfoRad, it's just about impossible to tell you what's wrong or what InfoRad expects your code to be doing.
The generic answer would be to make sure the serial port parameters are correct (it doesn't sound like it!) and that you're using the proper encoding when converting the bytes to a string. What the correct encoding would be is determined by InfoRad.
|
|
|
|
|
I have googled and googled but not found a single simple solution:
How to print the contents of a RichTextBox? The contents is text only and font courier 12.
|
|
|
|
|
Have you tried this[^] ? Although it is in C#, you will get an idea
|
|
|
|
|
Yes, I have tried it but it won't work with SharpDevelop (the IDE that I use to code VB.net). Is there any other way?
|
|
|
|
|
If you looked at the top of that page, there's a link to the VB.NET 2005 (.NET 2.0) version of the same code. Also, the code has absolutely nothing to do with the IDE you're using. It'll still work, even if you're using Notepad to type in the code.
|
|
|
|
|
Drop this component[^] on the form that contains the rich text box, then set the extended properties for the bounding rectangle and other options and then call the FormPrintHelper1.Print method.
|
|
|
|
|
I have gridview in mine code,it has check box control. I want to fetch those rows only which has been selected by checking the check box column.
Please suggest me what I need to do.
Ashish K. vyas
-- modified at 3:44 Thursday 29th November, 2007
Ashish K. vyas
|
|
|
|
|
I use this to get the IDs (in the first column) you should be able to modify it to get the checked value from the checkbox cell
Private Sub DoReturns()<br />
Try<br />
Dim oRow As DataGridViewRow<br />
mvReturnValue = ""<br />
mvReturnValues = ""<br />
If dgData.SelectedRows.Count > 0 Then<br />
mvReturnValue = dgData.SelectedRows(0).Cells(0).Value.ToString<br />
For Each oRow In dgData.SelectedRows<br />
mvReturnValues += oRow.Cells(0).Value.ToString + ","<br />
Next<br />
End If<br />
Catch Exc As Exception<br />
Throw Exc<br />
End Try<br />
End Sub
Quote from Great Outdoors:
its a confident traveller who farts in India
|
|
|
|
|
Please read the forum guidelines. Avoid text speak. We don't care if it's urgent.
|
|
|
|
|
Hi, I'm (trying) to build an app using VB.net that will be a stand alone app. ie NOT a web based form etc.
The main reason for this is that I have a number of offline functions it will eventually do.
However, one part of the app is required to upload a file to a site via FTP and then make the file visible for others to download. There are more functions it needs to do, but essentially this is the main focus.
My problem is, i dont even know where to start to look to get an idea of how to do this. ie do I use ASP.Net, do I use AJAX or remoting??
If anyone has any suggestions or even some example code on how to manipulate a web site from a stand along App I would be forever grateful.
Ive some code to manage the File transfer, but I need to add links etc to the file/directory.
Any and all suggestions are welcome.
|
|
|
|
|
AGB11 wrote: any suggestions
Make sure you have aspirins because converting from web app to stand alone win apps are a total headache.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Currently I'm using VB.Net to perform a http/https multipart form post to a servlet. I'm able to perform the post using HttpWebrequest via GetRequestStream(). However, the servlet returned me with "The remote server returned an error: (500) Internal Server Error". Obviously, this means that I have not posted all the parameters as the servlet requested. But I just can't seem to find out what went wrong with my code. Hope someone can enlighten me, below is the code and sample form post for your reference:
VB.Net code:
Public Shared Function Send(ByVal URL As String, _
Optional ByVal Port As String = "", _
Optional ByVal Servlet As String = "", _
Optional ByVal PostString As String = "", _
Optional ByVal SSL As Boolean = Nothing, _
Optional ByVal faxfile As String = "", _
Optional ByVal faxlist As String = "")
'https handling
Dim oCertOverride As New CertificateOverride
ServicePointManager.ServerCertificateValidationCallback = AddressOf oCertOverride.RemoteCertificateValidationCallback
'set Port number
If Port = "" Then
If SSL = False Then
Port = 80
ElseIf SSL = True Then
Port = 443
End If
End If
'set the URL according to SSL
If SSL = True Then
URL = "https://" & URL & ":" & Port & Servlet
ElseIf SSL = False Then
URL = "http://" & URL & ":" & Port & Servlet
Else
Return ""
Exit Function
End If
'fax file
Dim boundary As String = "----------------------------------------AaB03x"
Dim contentLength
Dim postData2 = boundary & vbCrLf & "Content-Disposition: form data; name = ""faxfile""; " & _
"filename= """ & faxfile & """" & vbCrLf & _
"Content-Type: image/tiff" & vbCrLf & vbCrLf
Dim faxStream As New FileStream(faxfile, FileMode.Open, FileAccess.Read)
Dim faxBuffer() As Byte
ReDim faxBuffer(Math.Min(4095, faxStream.Length))
'fax list
Dim postData3 = ""
Dim listStream As FileStream = Nothing
Dim listBuffer() As Byte = Nothing
If faxlist <> "" Then
postData3 = boundary & vbCrLf & "Content-Disposition: form-data; name = ""faxlist""; " & _
"filename=""" & faxlist & """" & vbCrLf & _
"Content-Type: text/plain" & vbCrLf & vbCrLf
listStream = New FileStream(faxlist, FileMode.Open, FileAccess.Read)
ReDim listBuffer(Math.Min(4095, listStream.Length))
End If
'end boundary
Dim postData4 = vbCrLf & boundary & "--"
MsgBox(PostString & postData2 & postData3 & postData4) 'debug
'convert to bytes
Dim byte1() As Byte
Dim byte2() As Byte
Dim byte3() As Byte = Nothing
Dim byte4() As Byte
byte1 = System.Text.Encoding.ASCII.GetBytes(PostString)
byte2 = System.Text.Encoding.ASCII.GetBytes(postData2)
byte4 = System.Text.Encoding.ASCII.GetBytes(postData4)
'populate content length
contentLength = byte1.Length + byte2.Length + faxStream.Length + byte4.Length
If faxlist <> "" Then
byte3 = System.Text.Encoding.Default.GetBytes(postData3)
contentLength = contentLength + byte3.Length + listStream.Length
End If
Dim Request As HttpWebRequest = WebRequest.Create(URL)
Dim Response As HttpWebResponse
Dim ResponseData As String = ""
' Prepare Request Object
Request.Method = "POST"
Request.AllowWriteStreamBuffering = False
Request.ContentType = "multipart/form-data; boundary=" & boundary
Request.Accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, image/tiff, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-shockwave-flash, */*"
Request.Headers.Add("Cache-Control", "no-cache")
Request.UserAgent = "http generic"
System.Net.ServicePointManager.Expect100Continue = False
Request.ContentLength = contentLength
MsgBox(Request.ContentLength.ToString()) 'debug
Dim SW As Stream = Nothing
Dim SR As StreamReader = Nothing
' Send Request, If Request
Try
SW = Request.GetRequestStream()
If SW.CanWrite Then
MsgBox("Writing header") 'debug
SW.Write(byte1, 0, byte1.Length)
MsgBox("Writing fax file") 'debug
SW.Write(byte2, 0, byte2.Length)
Dim bytesRead = 1
While bytesRead <> 0
bytesRead = faxStream.Read(faxBuffer, 0, faxBuffer.Length)
If bytesRead <> 0 Then
SW.Write(faxBuffer, 0, bytesRead)
End If
End While
If faxlist <> "" Then
MsgBox("Writing fax list")
SW.Write(byte3, 0, byte3.Length)
bytesRead = 1
While bytesRead <> 0
bytesRead = listStream.Read(listBuffer, 0, listBuffer.Length)
If bytesRead <> 0 Then
SW.Write(listBuffer, 0, bytesRead)
End If
End While
End If
MsgBox("Writing end boundary")
SW.Write(byte4, 0, byte4.Length)
End If
Catch Ex As WebException
MsgBox(" Writing Exception: " & Ex.Message)
Catch Ex As Exception
MsgBox("Writing Exception: " & Ex.Message)
Return Nothing
Exit Function
Finally
SW.Close()
End Try
' Receive Response
Try
MsgBox("Receiving data") 'debug
Response = Request.GetResponse()
'MsgBox("retrieving from site") 'debug
SR = New StreamReader(Response.GetResponseStream())
ResponseData = SR.ReadToEnd()
MsgBox(ResponseData) 'debug
SR.Close()
Catch Ex As WebException
MsgBox("Servlet Exception: " & Ex.Message)
Catch Ex As Exception
MsgBox("Servlet Exception: " & Ex.Message)
Return ""
Exit Function
End Try
Return ResponseData
End Function
Sample multipart form post:
----------------------------------------AaB03x
Content-Disposition: form data; name="destnum"
12345678;
----------------------------------------AaB03x
Content-Disposition: form data; name="loginname"
test
----------------------------------------AaB03x
Content-Disposition: form data; name="password"
test
----------------------------------------AaB03x
Content-Disposition: form data; name="line"
1
----------------------------------------AaB03x
Content-Disposition: form data; name="faxpri"
0
----------------------------------------AaB03x
Content-Disposition: form data; name="scheduletype"
1
----------------------------------------AaB03x
Content-Disposition: form-data; name = "faxfile"; filename="C:\Users\test\Appdata\Roaming\WindowsApplication1\Application1\1.0.0.0\Microsoft Word - Document1.TIF"
Content-Type: image/tiff
follow by file content
----------------------------------------AaB03x--
Any help will be appreciated
~ amelia ~
|
|
|
|
|
I dragged and dropped a database table to my form. Then I wrote some code that is not in the designer generated code. It is a sub routine for one of my tab pages.
Here is the code.
Private Sub tabpgSettings_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tabpgSettings.Click<br />
' declare variables<br />
<br />
'TODO: This line of code loads data into the 'DataSet1.tbl_hours' table. You can move, or remove it, as needed.<br />
' use the try block in case of an error<br />
<br />
Try<br />
Me.Tbl_hoursTableAdapter.Fill(Me.DataSet1.tbl_hours)<br />
Catch err As Exception<br />
MessageBox.Show(err.Message)<br />
End Try<br />
<br />
' fill the Mon - Sun combo boxes with the hours<br />
<br />
End Sub
As soon as I pasted this code into the class I went back to the form designer and the form would not come up and there were a bunch of errors instead.
Here are the errors that showed up instead of the form.
One or more errors encountered while loading the designer. The errors are listed below. Some errors can be fixed by rebuilding your project, while others may require code changes.
Why does it mention this code below? The code is not on 2006, it is on line 2010.
The designer cannot process the code at line 2006: Me.DataSet1.DataSetName = "DataSet1" The code within the method 'InitializeComponent' is generated by the designer and should not be manually modified. Please remove any changes and try opening the designer again. <br />
Hide Edit <br />
<br />
at Microsoft.VisualStudio.Design.Serialization.CodeDom.XML.CodeDomXmlProcessor.CreateQuoteExpression(XmlElementData xmlElement)<br />
at Microsoft.VisualStudio.Design.Serialization.CodeDom.XML.CodeDomXmlProcessor.XmlElementData.get_CodeDomElement()<br />
at Microsoft.VisualStudio.Design.Serialization.CodeDom.XML.CodeDomXmlProcessor.EndElement(String prefix, String name, String urn)<br />
at Microsoft.VisualStudio.Design.Serialization.CodeDom.XML.CodeDomXmlProcessor.Parse(XmlReader reader)<br />
at Microsoft.VisualStudio.Design.Serialization.CodeDom.XML.CodeDomXmlProcessor.ParseXml(String xmlStream, CodeStatementCollection statementCollection, String fileName, String methodName)<br />
at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomParser.OnMethodPopulateStatements(Object sender, EventArgs e)<br />
at System.CodeDom.CodeMemberMethod.get_Statements()<br />
at System.ComponentModel.Design.Serialization.TypeCodeDomSerializer.Deserialize(IDesignerSerializationManager manager, CodeTypeDeclaration declaration)<br />
at System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager manager)<br />
at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager serializationManager)<br />
at System.ComponentModel.Design.Serialization.BasicDesignerLoader.BeginLoad(IDesignerLoaderHost host)
Here are the errors that showed up in the designer generated code. It says that the designer generated code was edited but I did not edit it.
The code below has a blue squigly line under "LessonProgram".
Friend WithEvents DataSet1 As LessonProgram.DataSet1<br />
Friend WithEvents Tbl_hoursTableAdapter As LessonProgram.DataSet1TableAdapters.tbl_hoursTableAdapter<br />
Me.DataSet1 = New LessonProgram.DataSet1<br />
Me.Tbl_hoursTableAdapter = New LessonProgram.DataSet1TableAdapters.tbl_hoursTableAdapter
I replaced the above lines of code with the following lines and the blue line dissapeared, but the form still wotn come up.
Friend WithEvents DataSet1 As DataSet1<br />
Friend WithEvents Tbl_hoursTableAdapter As DataSet1TableAdapters.tbl_hoursTableAdapter<br />
Me.DataSet1 = New DataSet1<br />
Me.Tbl_hoursTableAdapter = New DataSet1TableAdapters.tbl_hoursTableAdapter
Also, it said that the designer can't process the code at line 2006. This is what is on line 2006.
Me.Label61.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
Has anyone ever had this happen and do you know how to fix it?
|
|
|
|
|
You said that you pasted that code into your project. Make sure that tabpgSettings's click event is attached to that sub.(form design window>tabpgSettings's properites>Events>)
Make sure you didnt delete "End Class" or "Public Class Form1"
Undo the changes you made to:
"Friend WithEvents DataSet1 As LessonProgram.DataSet1
Friend WithEvents Tbl_hoursTableAdapter As LessonProgram.DataSet1TableAdapters.tbl_hoursTableAdapter
Me.DataSet1 = New LessonProgram.DataSet1
Me.Tbl_hoursTableAdapter = New LessonProgram.DataSet1TableAdapters.tbl_hoursTableAdapter"
once you fix the first error this one will go away as well.
If that doesnt work I would press undo (Ctrl+z) about 300 times to find out what you deleted.
Its not the best advice but it will work.
|
|
|
|
|
I checked and I did not delete any code at all. In fact, no matter what I do I get these errors. I don't get these errors if I do not drag and drop a database table to the form.
Here is exactly what I am doing.
1) I drag and drop a data base table to the form from the Data Sources window which adds the TableAdapter etc to the form.
2) If I type any code -- OR -- hit the enter key so that I can type code after a comment -- OR -- put a ' before some code to make it a comment or type any code at all I get these errors.
I even downloaded SP1 for Visual Basic Express 2005 and it did not fix the errors.
Does anyone have any idea at all what is causing this error?
Are there any known bugs with adding tableAdapters using Visual Basic Express 2005?
Is there anyone else out there that is having this same problem?
|
|
|
|
|
Im trying to load a Crystal Report I've made in Visual Studio to a Crystal Report Viewer on my form. I used the "database expert" to add the connection (ODBC RDO) to my Access 2007 database. The database has no password on it.
The Visual Studio field explorer detects all the fields correctly from my command ( SELECT * FROM Table1; ) so I know it can connect to the databse.
The problem is when I run the program I get prompted for the Logon ID and Password and every time I get "Logon Failed. Please Try Again." Again there is no password on this DB.
All of my code (this is a test project)
Imports CrystalDecisions.CrystalReports.Engine
Form Load:
Dim crpt As New ReportDocument()
Dim rPath As String = "C:\CrystalReport1.rpt"
crpt.Load(rPath)
CrystalReportViewer1.ReportSource = crpt
|
|
|
|
|
Are you supplying it with the right log in credentials? Or have you not been required to do so?
"I've seen more information on a frickin' sticky note!" - Dave Kreskowiak
|
|
|
|
|
I thought that was handled by the ODBC RDO.
As I said it can connect to the DB when Im in the Crystal Report Design window but when I run the program it prompts for a Logon ID and Pass but there is no need for this info to make a connection.
I read that setting "Persist Security Info" on the connection is supose to fix this but I'm unsure how to apply this setting.
|
|
|
|
|
Do I have to open and close the database connection when using TableAdapters like I would with DataAdapters?
|
|
|
|