|
Give this a try. What I've done is added a handler for the child forms formclosed event. This way we know when the child is closed and can close too.
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim a As New Form1
'Register our method (ChildClosed) with the new forms FormClosed event
AddHandler a.FormClosed, AddressOf ChildClosed
a.Show()
End Sub
'When the child closes this method will run which will close the current form
Private Sub ChildClosed(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosedEventArgs)
Me.Close()
End Sub
End Class
***EDIT***
Also what are you doing to go back?
**EDIT2***
Oh, ya. You can also just use 'End' or 'Application.exit' to shutdown everything. I forgot about the easy answer
|
|
|
|
|
yeah this End and application.exit are working...
well to go back i am coding like this..
suppose i am on form 2 and button "back"
in back_click
dim a as new form1
me.close() ' to close the existing form
a.show()
here thing is a new form1 gets open by this method...
what if i want same form1 which is hidden...??
any idea.?
|
|
|
|
|
You could use the same code I posted earlier. However, instead of closing form1 when the child is closed you would just show it. Form2 doesn't need to worry about form1 at all in this case. When the back button is clicked just call me.close. Form1's method will then get called because you registered that method with form2's closed event.
|
|
|
|
|
The right way to do this, is to have the two forms defined as user controls and showing them both on the one form, your button changes which is visible.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi to all,
how can I build the base64_decode in VB.NET?
I have found this code but I don't know how can I use it. The decoded string is an image. How can I display it?
This is the code:
<br />
<br />
Private Const base64 = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789+/"<br />
<br />
Private Function base64_decode(ByVal a As String) As String<br />
Dim w1 As Integer<br />
Dim w2 As Integer<br />
Dim w3 As Integer<br />
Dim w4 As Integer<br />
Dim n As Integer<br />
Dim retry As String<br />
<br />
For n = 1 To len(a) Step 4<br />
w1 = mimedecode(mid$(a, n, 1))<br />
w2 = mimedecode(mid$(a, n + 1, 1))<br />
w3 = mimedecode(mid$(a, n + 2, 1))<br />
w4 = mimedecode(mid$(a, n + 3, 1))<br />
If w2 >= 0 Then retry = retry + Chr(((w1 * 4 + Int(w2 / 16)) And 255))<br />
If w3 >= 0 Then retry = retry + Chr(((w2 * 16 + Int(w3 / 4)) And 255))<br />
If w4 >= 0 Then retry = retry + Chr(((w3 * 64 + w4) And 255))<br />
Next<br />
base64_decode = retry<br />
End Function<br />
<br />
Private Function mimedecode(ByVal a As String) As Integer<br />
If Len(a) = 0 Then mimedecode = -1 : Exit Function<br />
mimedecode = InStr(base64, a) - 1<br />
End Function<br />
<br />
This is the encoded image:
<br />
/9j/4AAQSkZJRgABAQAAAQABAAD
I would like to show it in a image control.
Thanks
|
|
|
|
|
You don't have to build it, it's already there. Convert.FromBase64String .
---
single minded; short sighted; long gone;
|
|
|
|
|
|
hello everyone!!
can v add validations for textboxes (insertions by user) in a windows application as in a web application
my problem is wit the registration form wherein i need to check tat a person enters a valid phone-no. etc..
|
|
|
|
|
Sure. This[^] is the beginning of a 3 part series of articles covering that very topic. Be sure to find the other two articles in the navigation pane on the left.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
what type of validation do you want exactly...?
like in that textbox of phone no u dont want that user could enter any character, dots space etc...?????
is it like that...?
specify in some detail..
|
|
|
|
|
yes, like in the textbox to enter a number, text should not b added and in a box for user's name, no numbers
|
|
|
|
|
like if u want to enter only digits and no alphabets make a keypress event like this
Private Sub Text1box_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress<br />
Dim KeyAscii As Short = Asc(eventArgs.KeyChar)<br />
Select Case KeyAscii<br />
Case 48 To 57 '0 To 9<br />
Case 8 'Back Space<br />
Case 13 'Enter<br />
Case Else 'Other Keys<br />
KeyAscii = 0<br />
End Select<br />
If KeyAscii = 0 Then<br />
eventArgs.Handled = True<br />
End If<br />
End Sub
if you want only alphabets no digits then in case just enter the ascii of alphebets...
and also if u want to validate more than one textboxes then in keypress event after handles textbox1.keypress put textbox2.keypress, textbox3.keypress...and so on..
i had the same problem and got solution on this forum only around a week ago...check out that post wid heading 'validating textboxes'
|
|
|
|
|
You can handle the keypress event of your textbox, and set handled to true if it's a character you don't want. You can handle the leave event, and set focus back on the control if the input is not valid ( use a regex, probably )
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I want to program a checkbook register in VB.Net 2.0 (on XP, not Vista). I have a couple of ideas on how to store the data. But I'm stuck at even how to begin representing the register on the screen. Can anyone give me some hints, tips, ideas in that regard?
Thanks,
Owen
|
|
|
|
|
Worry about how you're going to represent the data first. Answer the basic questions first. What transactions are you going to handle? What is the information needed to perform each transaction? Stuff like that. It'll make your data layer much easier to write if you lay everything out ahead of time. Basically, you want this data layer to be able to do anything you want to the data, without any kind of a user interface.
How the transactions are setup and executed is the domain of the business layer. It sits between your UI and data layers and enforces all the rules for each transaction. Data is validated and massaged on this layer before any kind of transaction is built and executed by your data layer.
Now, after those two are done, the user interface practically writes itself. You start with a simple interface and build it up from there. Maybe using some textboxes and buttons. Simple. Then when your ready to move up to more complex, custom drawn interface elements, like filling in an actual image of a check, you just have to modify the UI layer.
I've got an "application" written entirely in SQL Server, a small football pool. It doesn't have any user interface at all but runs entirely inside SQL Server. The business logic (transactions) and data layers have been combined enitrely into SQL stored procedures, Views, and Triggers. The entire data model is defined inside the SQL database.
You can run the app entirely using nothing but simple SQL statements, or, if you wanted just opening the tables and start editing them directly, like adding players, games, changing the scoring model, whatever... You can view current standings or any game details by just opening the View you want. You can't screw up the database with invalid data because the validation rules in the business logic inside the SP's and Triggers won't let you. The database defends itself from bad data entirely on its own. It doesn't need a seperate business layer written in .NET code to keep the data safe.
Now, all I have to do is put together a number of user interfaces for the app, like an ASP.NET application and/or a Windows Forms app.
Why did I say all this?? Because if you need to change how the application looks, you don't have to touch the business and data layers at all. The application can still run, even if you chose to use a simple console app as the user interface!
Want to run this in a web browser? No problem! Just add an ASP.NET project to the solution and you can start building a web-based UI for the exact same app.
Really, this is a great little project to teach yourself how to write n-tier applications.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Exactly. The data representation has very little, if any, effect on the UI. For a start, I'd like to figure out how to display a column of numbers with their descriptions in something that looks like either a checkbook register or a ledger book page -- the UI will not be adding or subtracting, just showing the data. (When I say "looks like", I don't mean it looks like someone wrote in the entries by hand: I mean that the display has columns and rows and the background color is a light green.).
Thanks,
Owen
|
|
|
|
|
DataGridView would do this easily. If you wanted colored alternating rows, that'd take a bit more work.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
OK. Thanks. I'll check out DataGridView.
|
|
|
|
|
My platform: VB.NET Windows Form
My case:
DOS program mon.exe runs on command window. This program enables you to monitor a flash ram. To monitor ipno 10.0.0.90 from 4000 port you just type:
C:\>mon 10.0.0.90 4000
Which can also be performed by VB.NET with command line:
Shell("mon " & ipno & " 4000", AppWinStyle.MaximizedFocus, True)
After mon.exe executes you are monitoring the ipno and a command line occurs.
10.0.0.90\>
To change the ipno you type SET IP newIP:
10.0.0.90\> SET IP 10.0.0.44
At this point, I am not able to execute SET IP command line. I tried to create batch file but it didn't work. I tried :
System.Console.Write("SET IP" & newIP) 'but it didn't work.
I am trying to develop a Windows Form to change the ip of a special system. Can anyone help me? Should I work on batch files? Is there a way to type on command window while shell command is executing?
I will be really appriciated for an answer.
B.B.
|
|
|
|
|
You can't type into a Shell'd process from VB.NET. You have to create your own process using the Process class. You can then redirect the StandardInput stream so you can have your code type in the command window. You can't do this using Shell.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Thanks. I will try. It will take some time. But will post the result.;)
B.B.
|
|
|
|
|
Is it right below? To start monitoring? It does not seem to work properly.
Dim objProcess As New Process
' Start the Command and redirect the output
objProcess.StartInfo.UseShellExecute = False
objProcess.StartInfo.RedirectStandardOutput = True
objProcess.StartInfo.CreateNoWindow = False
objProcess.StartInfo.RedirectStandardError = True
objProcess.StartInfo.WorkingDirectory = CurDir()
objProcess.StartInfo.FileName() = "mon"
objProcess.StartInfo.Arguments = " 10.0.0.99 4000"
objProcess.Start()
|
|
|
|
|
Well, you got most of it right. The only stream you didn't redirect was StandardInput. That's the keyboard stream that let's you "type" something into that console session.
Dim objProcess As New Process
With objProcess.StartInfo
.UseShellExecute = False
.CreateNoWindow = False
.RedirectStandardInput = True
.RedirectStandardOutput = True
.RedirectStandardError = True
.FileName = "mon"
.Arguments = " 10.0.0.99 4000"
End With
objProcess.Start()
Then to write to the console keyboard stream:
Dim kb As StreamWriter = objProcess.StandardInput
kb.WriteLine("This is being typed in the console session...")
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
When I make the StandardInput = True
objProcess.StartInfo.RedirectStandardInput = True
it opens the command window but does not give any result of mon.exe. It is not enabled also.
If StandardInput = False then mon.exe works fine but command window only lets input from keyboard.
Should I Import any dll?
B.B.
|
|
|
|
|
I have no idea. I've never sen anything like that. You might want to try it with a different executable. When I did something like this, it took some playing around to get all the redirect settings to work properly. You've got everything that I've used before working.
If your app isn't worried about what's comming back from MON, turn off the redirection of StandardError and StandardOutput.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|