|
Still trying to figure out why I can't send a mail message. Switched from SendAsync to Send, and got the following error message:
System.Net.Mail.SmtpException: Failure sending mail. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
--- End of inner exception stack trace ---
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.DelegatedStream.Read(Byte[] buffer, Int32 offset, Int32 count)
at System.Net.BufferedReadStream.Read(Byte[] buffer, Int32 offset, Int32 count)
at System.Net.Mail.SmtpReplyReaderFactory.ReadLines(SmtpReplyReader caller, Boolean oneLine)
at System.Net.Mail.SmtpReplyReaderFactory.ReadLine(SmtpReplyReader caller)
at System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port)
at System.Net.Mail.SmtpTransport.GetConnection(String host, Int32 port)
at System.Net.Mail.SmtpClient.GetConnection()
at System.Net.Mail.SmtpClient.Send(MailMessage message)
--- End of inner exception stack trace ---
at System.Net.Mail.SmtpClient.Send(MailMessage message)
at SammiText.SendMail.tb_Send_Click(Object sender, EventArgs e) in **deleted**.vb:line 51
--------------------------------------------------------------------
The code I'm using presently is:
Dim mail As New MailMessage(from my e-mail, to my e-mail, "TEST SUBJECT", "TEST BODY")
sndr.UseDefaultCredentials = False
sndr.Credentials = New NetworkCredential(my user name, my password)
sndr.EnableSsl = True
sndr.DeliveryMethod = Net.Mail.SmtpDeliveryMethod.Network
Me.Text = "Sending..."
Me.WindowState = FormWindowState.Minimized
Try
sndr.Send(mail)
Catch ex As Exception
dialog_Debug.errTXT.Text = ex.ToString
dialog_Debug.ShowDialog()
End Try
|
|
|
|
|
For this project, you will implement Conway’s game of Life as an assembly language program.
Background: John Horton Conway was a mathematician at Gonville and Caius College of the University of Cambridge. Most of his work was in pure mathematics, but he also applied his considerable talents towards recreational pursuits. The game of Life is one of these. Conway postulated “genetic laws” for births, deaths, and survival that applied to counters (occupied cells) who lived on a simple two-dimensional grid. On an infinite grid, each cell would enjoy the company of eight other neighboring cells. An initial pattern of cells is defined to be occupied, and then the rules are applied in a turn-based fashion.
Rules:
Survivals – Every occupied cell with two or three neighboring occupied cells survives for the next generation.
Deaths – Each occupied cell with four or more neighboring occupied cells dies (is removed) from overpopulation. Every occupied cell with no neighboring occupied cells or only one neighboring occupied cell dies from isolation.
Births – Each empty cell that is adjacent to exactly three occupied neighboring cells is a birth cell. That cell will become occupied on the next turn.
All births and deaths occur simultaneously. Taken together they constitute a single generation or turn. Each turn consists of identifying the cells where death will occur, then determining the cells where births will occur and making these changes at the same time.
Your program will run as a simple console application using a grid that is 25 rows by 80 columns in size. Feel free to take advantage of the routines made available by our author, but use only these routines or your own original code. Your program should greet the user and allow them to select from one of three options. The first option is to read a file containing an initial layout of occupied and unoccupied cells. The input files will be ASCII text files. Each file will consist of 25 rows of data. Each row of data will be 82 characters long, 80 characters (1’s or 0’s) plus the carriage return and the line feed characters. The second option should offer the user a chance to randomize the initial layout of occupied cells by identifying how many of the cells should be occupied initially. The third option that you should make available to the user is a choice to terminate execution of your program.
Occupied cells should be represented as dark objects on a light background. Your program should operate at about three turns per second and run until one hundred turns have been completed OR there are no occupied cells in the grid. A typical execution should take a little over thirty seconds.
Your program shold properly read a formatted file that contains an initial layout of occupied cells and runs to normal completion. Normal completion consists of no execution errors, successful display, and then another offer of the basic choices to the user.
your program should detect errors within the input file, identify all of the errors to the user, replace invalid characters with the symbol for an unoccupied cell, and run to normal completion. The valid ASCII character for an occupied cell is the character representation for one (1). An empty or unoccupied cell is indicated by the character zero (0). Anything else is considered an invalid character.
You may implement the feature of randomized initialization. Randomized initialization consists of determining on a random basis whether a cell is initially occupied. This can be done by asking the user how many cells should be occupied initially out of the total number of cells in your grid. Then use the ratio of the number of requested occupied cells to the total number of cells as the probability to determine on a cell by cell basis if each cell will be initially occupied or empty. Don’t forget to guard against the user requesting that more cells be initially occupied than exist in your grid.
You may implement a wrap-around feature. Wrap-around simply means that you should consider the right edge to be touching the left edge and the top edge to be touching the bottom edge. A moving figure that approaches the right edge will not disappear with wrap-around implemented, but will instead re-appear from the left edge.
You can add a fourth optional choice that permits the user to control the number of turns or the speed of the display.
Other enhancements, such as the tasteful use of color or sound can be considered. If the program terminates prior to 100 turns, you might wish to tell the user the turn number at which it stopped. The user interface is “where the rubber meets the road” in any program. Pay attention to this important aspect of your program to receive the maximum points.
References: There are many references that illustrate and discuss Conway’s game of Life.
An article in Scientific American 223 (October 1970): pages 120-123 by Martin Gardner in his monthly Mathematical Games column was used in large part.
|
|
|
|
|
No one on this site is going to help you unless you show us you spent real effort yourself, got stuck somewhere and come up with a specific question. It is your assignment, not ours.
|
|
|
|
|
maheshgtm wrote: as an assembly language program.
You're going to fail your course. We would not do your homework if you asked a VB question, but to ask an assembly question here is the height of cluelessness.
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
Goal: Use VB application to submit multiple values to a webform
I have the data I want to send to the xxxxx.com website collected from fiddler2. I used fiddler 2 to post and it works. I would like to use this information like fiddler2 is using to execute the submit button.
fiddle information:
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-silverlight, application/x-silverlight-2-b2, application/x-ms-application, application/x-ms-xbap, application/vnd.ms-xpsdocument, application/xaml+xml, */*
Referer: http://xxxxxxxxxxxxxxxxxxxxxxxxx.com/
Accept-Language: en-us
Content-Type: multipart/form-data; boundary=---------------------------7d93aa14e06c8
UA-CPU: x86
Connection: Keep-Alive
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; InfoPath.1; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; MS-RTC LM 8)
Pragma: no-cache
Content-Length: 20603
Host: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.com
Cookie: HPF_Group=1; sauid=U3344282; JSESSIONID=(J2EE200)ID19737905End; SAPWP_active=1; sap-ssolist=O3I9Q1JNUFJEQVAwQl9DTVBf%3D; sasid=S99024; sa_uvc=U3396744282
and the following as a sample:
-----------------------------7d93aa14e06c8
Content-Disposition: form-data; name="__EVENTTARGET"
-----------------------------7d93aa14e06c8
Content-Disposition: form-data; name="__EVENTARGUMENT"
-----------------------------7d93aa14e06c8
Content-Disposition: form-data; name="__LASTFOCUS"
Dim url As String = "http://xxxxxxxx.com/"
Dim oWeb As New System.Net.WebClient()
oWeb.Headers.Add(HttpRequestHeader.Accept, "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-silverlight, application/x-silverlight-2-b2, application/x-ms-application, application/x-ms-xbap, application/vnd.ms-xpsdocument, application/xaml+xml, */*")
oWeb.Headers.Add(HttpRequestHeader.Referer, "http://xxxxxxx.com/")
oWeb.Headers.Add(HttpRequestHeader.AcceptLanguage, "en-us")
oWeb.Headers.Add(HttpRequestHeader.ContentType, "multipart/form-data; boundary=---------------------------7d93aa14e06c8")
oWeb.Headers.Add(HttpRequestHeader.Connection, "Keep-Alive")
oWeb.Headers.Add(HttpRequestHeader.UserAgent, "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; InfoPath.1; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; MS-RTC LM 8)")
oWeb.Headers.Add(HttpRequestHeader.Pragma, "no-Cache")
oWeb.Headers.Add(HttpRequestHeader.ContentLength, "30603")
oWeb.Headers.Add(HttpRequestHeader.Host, "http://xxxxxxx.com/")
oWeb.Headers.Add(HttpRequestHeader.Cookie, "HPF_Group=1; sauid=U3 712!56hE mIQ%3D%3D; sasid=S593 99024; sa_uvc=U339 05744282")
Try
oWeb.UploadString(url, "POST", TextBox1.ToString)
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
I also tried the following way. Got a little sloppy after a while. This is how I last left it before my head started hurting
Dim objEncoding As New System.Text.UTF8Encoding
Dim objStream As System.IO.Stream
Dim objHTTPRequest As HttpWebRequest
Dim sbPostData As New System.Text.StringBuilder
Dim objStreamReader As System.IO.Stream
Dim strResult As String
'set request properties
objHTTPRequest = System.Net.WebRequest.Create("http://xxxxxxxxxxxxxxx.com/")
objHTTPRequest.AllowAutoRedirect = True
objHTTPRequest.Accept = "*/*"
objHTTPRequest.KeepAlive = False
objHTTPRequest.Timeout = 30000
objHTTPRequest.Method = "POST"
objHTTPRequest.ContentType = "multipart/form-data; boundary=7d93aa14e06c8"
objHTTPRequest.Accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-silverlight, application/x-silverlight-2-b2, application/x-ms-application, application/x-ms-xbap, application/vnd.ms-xpsdocument, application/xaml+xml, */*"
objHTTPRequest.Referer = "http://xxxxxxxxxxxxxxxxx.com/"
' objHTTPRequest.a.Accept-Language = "en-us")
objHTTPRequest.ContentType = "multipart/form-data; boundary=---------------------------7d93aa14e06c8"
' objHTTPRequest.u.UA-CPU = "x86")
'objHTTPRequest.Connection = "Keep-Alive"
objHTTPRequest.UserAgent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; InfoPath.1; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; MS-RTC LM 8)"
' objHTTPRequest.Pragma = "no-Cache")
objHTTPRequest.ContentLength = "30603"
' objHTTPRequest.Host = "http://xxxxxxxxxxxxxxxx.com/")
' objHTTPRequest.Cookie = "HPF_Group=1; sauid=U33961282; JSESSIONID=(J2EE117803200)ID1972977451DB11724142932769437905End; SAPWP_active=1; sap-ssolist=!56hEH4wnxXmIQ%3D%3D; sasid=S5939024; sa_uvc=U3344282")
'convert our other post data into a byte array
Dim bytPostContents As Byte() = objEncoding.GetBytes(boundry().ToString)
'get our stream and post our data
objStream = objHTTPRequest.GetRequestStream()
'close our stream
' objStream.Close()
'get the response from the server
Dim objHTTPResponse As HttpWebResponse = CType(objHTTPRequest.GetResponse(), HttpWebResponse)
objStreamReader = objHTTPResponse.GetResponseStream()
'final result from server is returned to strResult
Dim objStreamResult As New System.IO.StreamReader(objStreamReader)
strResult = objStreamResult.ReadToEnd
'close our objects
objStreamReader.Close()
objStreamResult.Close()
End Sub
|
|
|
|
|
I'm searching for a replace-funktion for controlselections.
I know, it is possible if you first delete and then add an new control but the control has to have the same index(=postion on the form) than before.
And I found no "addat"-funktion
Has someone an idea?
|
|
|
|
|
That depends on the collection you're using. The Controls collection in the Form class has no such facility, and frankly, if your design relies on the order the controls have been added to it, you need to rethink your design. You shouldn't be using the index in the collection to find controls. You should be positively identifying controls using things such as their name or some other ID you put in the control's Tag property.
|
|
|
|
|
Create the new control in your code, then find the old control by looping through your form's control collection and checking the type of the controls, or the name of each control. When you find the one you're looking for, convert it (using Ctype) to the new one. This way the index doesn't change.
Here's an example of using Ctype. I use this method in a tabbed text editor with an extended RichTextBox class. The RTBs are contained in a collection ("allFiles") of type "myRTF" (the extended RTB). All editing is done with an in-memory RTB named "rtf". When the tab control's selected index changes, the following code gets the tab control's new SelectedIndex and finds the correct item in the collection:
index = tabs.SelectedIndex
rtf = CType(allFiles(index), myRTF)
The in-memory RTB ("rtf") is converted to the proper member of the collection. You can use a similar method to "insert" your new control without affecting the indexes in the control collection.
|
|
|
|
|
I have this application from several years ago that I am modifying.
I created a new form where I have an Xceed grid tied to a DataSet-DataAdapter. When the Add button (or a blank area on the grid) is clicked, it creates a new row. The user types information there and clicks "Save". Or the user edits an existing row and clicks "Save".
The data adapter calls the Update() method that invokes the corresponding SQL Insert/Update/Delete commands. It works fine.
But I have a link table where I want to Insert when a new row is saved in the previous table mentioned above. How do I know a new row has been created and "Save" button is clicked or an existing row is edited and the "Save" button is clicked?
I need some help please.
Thanks.
|
|
|
|
|
I got it done, thanks if you read it.
|
|
|
|
|
Hi,
With my datagridview I have column for datetime. I used the following for format.
Dim secidexp As New DataGridViewTextBoxColumn
With secidexp
.MaxInputLength = 10
.DataPropertyName = "sec_id_expiry"
.HeaderText = "ID EXPIRY DATE"
.DefaultCellStyle.Format = "dd/MM/yyyy"
End With
But the problem is it's getting input like MM/dd/yyyy and after pressing enter it's changing to dd/mm/yyyy style.
So is it possible to get input like "dd/MM/yyyy"
PS: This Problem occours only in Editing the rows & for New Rows.
Thanks ...
|
|
|
|
|
This is probably dependent on the culture info of the computer. Look into setting the culture info for the datagridview. I'm only guessing as I generally don't allow data entry into a grid control, I force the user to a details dialog for data manipulation where you have much finer control.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Basically, my goal is to get a multiline TextBox or a RichTextBox to resize the font of its text until all of the text can be seen. The following code works to make the text fit on one line, but I am not sure how to change it to work for multiple lines.
Public Shared Function BestFontSize(ByVal g As Graphics, _
ByVal z As Size, ByVal f As Font, ByVal s As String) As Single
Dim p As SizeF
p = g.MeasureString(s, f)
Dim hratio As Double = z.Height / p.Height
Dim wratio As Double = z.Width / p.Width
Dim ratio As Double = Math.Min(hratio, wratio)
System.Console.WriteLine(f.Size * ratio)
Return f.Size * ratio
End Function
Private Sub TextBox1_TextChanged(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles TextBox1.TextChanged
If TextBox1.Text <> "" Then TextBox1.Font = New Font(TextBox1.Font.FontFamily, _
BestFontSize(TextBox1.CreateGraphics, TextBox1.Size, TextBox1.Font, TextBox1.Text))
End Sub
Is there a way to determine which characters are actually visible on screen? Any ideas on a better way to do this?
|
|
|
|
|
I've done soemthing like this before. Basically, there's no function that will do this for you and no way to tell what has been drawn and what hasn't. What I did was use MeasureString with a starting font size, see if it fit in an available space, and if not, reduce the font size and measure it again. Keep going until you reach either a minimum acceptable font size or the drawn text finally fits.
Warning! This method can be slow and reduce your app's performance.
In a second version of the app I did, I ended up drawing the text to a bitmap in a fixed-size, but larger, font, then drawing that bitmap to the screen scaled to the proper size. The final drawn text quality suffered a little bit from the scaling, but the performance was much better.
|
|
|
|
|
Hi,
this is what I would try:
0.
choose fontsize fs1=10;
1.
use Graphics.MeasureString() with some font (fontsize fs1), the right width, and let it compute the height that would take. Make sure to give it all parameters equal to what you will use in the TextBox eventually.
2.
calculate a new fontsize as fs1 = fs1 * 0.9 * textboxHeight/measureStringHeight; (use floating-point!)
3.
since with a different font size word wrapping will be different too, iterate steps 1 and 2 say three times. (The 0.9 factor above is there to reduce the likelihood final text does overflow just a bit)
|
|
|
|
|
i am developing one eform designer project..the main object of this project is there a form in this controls are drag and drop.moving and deleting and editing the properties ..it's like a our .net designer how we drag and drop the controls ..so in my project i need to implement undo/Redo functionality..please give me the basic idea of this..(Please think like a our .net Designer (UNDO/REDO))
Thanks & regadrs
Dilip
|
|
|
|
|
Take a look at this blog[^], and see if it meets your needs.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
I would personally have a structure which a) describes what the user did, or b) describes the state of the control before the user interacted. Then I would use a Stack, and just push or pop the structures whenever the user clicks Redo or Undo respectively (I think)
|
|
|
|
|
You may want to do some research into the "command pattern".
|
|
|
|
|
I have to add one functionality in my Windows application. When user presses X key, it should do some function by calling routine. However when user is typing something on a form(ex. in textbox), this event should not be fired.
Currently due to this event handler code, user is unable to type X key becoz it is calling X key routine.
Any solution of this problem?
Thanks.
|
|
|
|
|
Maybe you could set a boolean flag which gets toggled when the user enters/leaves the textboxes on your form. The x key routine would then check the state of the boolean flag which would determine if the event should go ahead or not.
|
|
|
|
|
Thanks Liqz,
The situation is there is one main form and depending on menu items selection, it is loading user controls on main form, which comes from multiple solutions. So there are many solutions and lots of user controls are taking part here.
I do not want to change all the user controls but I want to change only main form.
Thanks.
|
|
|
|
|
Take a look at Tom's post below, it is actually a better solution than mine, I was unaware of the ActiveControl method.
Using that method you can get the type of the active control, then if the type of active control is a text box, don't do the x key function.
|
|
|
|
|
Use alt+x ?
Other than that in your function (that is called by the event handler on pressing x) check if the current active control is one where the user can type in (textbox, richtextbox,...)
This might be off help:
form.ActiveControl
|
|
|
|
|
Thanks Tom,
I looked for X key combination with Alt key but it is returning me only Alt key and not with combination of other key with Alt so i am unable to trap event for Alt+X key combination.
Also I looked on ActiveControl but the deal is I have layers of controls like this:
Bottom to top
Form
User Control
Split control
User control
Textbox and other controls.
When I tried to get active control, it returns me "System.Windows.Forms.SplitContainer" and not individual controls.
Any help please?
Thanks.
|
|
|
|
|