|
Change the Shutdown Mode in your project properties.
Trinity: Neo... nobody has ever done this before.
Neo: That's why it's going to work.
|
|
|
|
|
sorry i am not able to see any option in project property window...
can u explain a little bit more.....
|
|
|
|
|
manni_n wrote: sorry i am not able to see any option in project property window...
Are you using Visual Studio 2.0? If not, then just add Form1.close() to your close button on form2.
Trinity: Neo... nobody has ever done this before.
Neo: That's why it's going to work.
|
|
|
|
|
i am using VS 2003.
and about form1.close()
i have already used this one, its not working telling that refernce to non shares members need object refernce...
i am ussing me.close, but if i apply it on form2 then this works for form2 2 only , form1 still remains hidden..
|
|
|
|
|
manni_n wrote: i have already used this one, its not working telling that refernce to non shares members need object refernce...
It works fine for me. Could you post your full code for the Form2 close button?
Trinity: Neo... nobody has ever done this before.
Neo: That's why it's going to work.
|
|
|
|
|
there is no such great code involved in close button...
i have jst used like...
button2_click()
me.close()
end sub
thats it...
and if i also write form1.close
then its shows the error i told u in previous post....
you do one thing just tell me your way, i'll implement that method...
i just want to close all forms whenevr close button is clicked..
whether its on form2 or any other form say next form form3 or form4.
|
|
|
|
|
Alright, just to make sure, goto your project properties (Project Name Properties). Click Application , from there, you should have an option that says Shutdown Mode (or something similar). If there's no such option, then try the following:
<br />
Dim x As Integer<br />
For x = 0 To (Me.OwnedForms.Length) - 1<br />
Me.OwnedForms(x).Close()<br />
Next x<br />
Trinity: Neo... nobody has ever done this before.
Neo: That's why it's going to work.
|
|
|
|
|
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.
|
|
|
|