![]() Let's say that I said to you "if you're going to the shop, I'm going too" would you find that hard to comprehend? Of course not. It's simply a formalisation of that same logic. It seems to me that far too many people treat programming as though it exists in a vacuum and is divorced from the basic logic we all use every day. In this case, you only want to use the FileName if it is True that the value returned by ShowDialog is equal to OK. The Projects location field defines the default location for storing. True if the two values are equal and False if they aren't. Expand Projects and Solutions and click Locations. ![]() What would be the point if they didn't? The equality operator produces a Boolean value, i.e. It should be obvious that you only want to use the FileName property if the user clicked OK, so you need to test whether ShowDialog returned DialogResult.OK and then act only if it did.Īll operators produce a value. There may be times when you don't care what that value is but, when you display an OpenFileDialog, the user can select a file and click OK or they can click Cancel. The ShowDialog method returns a DialogResult value. It's about what action the user took in the dialogue. It's not about whether the dialogue has opened correctly. Next End If End SubEveryone forgive me for doing his homework. DialogResult.OK _įor Each Line In My.(OpenFileDialog1.FileName).Split( Environment.NewLine)ĭ(Split(Line, ControlChars.Tab)) OpenFileDialog1.Filter = "DAT Files (*.dat*)|*.dat" If OpenFileDialog1.ShowDialog = Windows.Forms. File.WriteAllText(SaveFileDialog1.FileName, DataGridView1.GetClipboardContent().GetText.TrimEnd)Įnd If End Sub Private Sub OpenButton_Click( ByVal sender As System. Then ' The DataGridView1.ClipboardCopyMode line ensures data stays in the correct column and row for savingĭataGridView1.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableWithoutHeaderText ![]() SaveFileDialog1.Filter = "DAT Files (*.dat*)|*.dat" If SaveFileDialog1.ShowDialog = Windows.Forms. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.ClickĬode: Private Sub SaveButton_Click( ByVal sender As System. Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Loadĭt.Columns.Add("Firstname", GetType(System.String))ĭt.Columns.Add("LastName", GetType(System.String)) Private Sub Form2_FormClosing(ByVal sender As Object, ByVal e As ) Handles Me.FormClosing
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |