This is getting quite absurd... vb.net programmers help solve..

Winston

Junior Contributor
Joined
Jan 25, 2003
Messages
266
Location
Sydney, Australia
Hey im kinda tierd of this

nothing seems to be working for me in vb.net


i hate how u have to instantiate a form
thats pathetic

the old vb was good... now it sucks...


i need help how to implement the most basic things


Changing the mainforms font


and

implementing a splash screen..
 
Are you using Visual Studio .NET or just the command line compiler?

You should go into the Code Library here on our forum and download some of the examples, they will give you a good idea of the basics.

Orbity
 
Have a look through these examples from Microsoft http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvssamp/html/vb_VBSamplesTop.asp Once you look through a few of those and assuming you have a good knowledge of VB6 creating a splash screen will be pretty straight forward for you.

To change the font of a form simply click once on the form to make it the selected control and then choose font from the properties window. Or to do it thruogh code you can do this:
From MSDN
Property Value
The Font object to apply to the text displayed by the control. The default is the value of the DefaultFont property.

Remarks
Because the Font object is immutable (meaning that you cannot adjust any of it's properties), you can only assign the Font property a new Font object. However, you can base the new font on the existing font.

The following is an example of how to adjust the existing font to make it bold:

C#:
myControl.Font = new Font(myControl.Font, 
   myControl.Font.Style | FontStyle.Bold);

Visual Basic:
MyControl.Font = New Font(MyControl.Font, _ 
   MyControl.Font.Style Or FontStyle.Bold)

Notes to Inheritors: When overriding the Font property in a derived class, use the base class's Font property to extend the base implementation. Otherwise, you must provide all the implementation. You are not required to override both the get and set accessors of the Font property; you can override only one if needed.

Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows .NET Server family

BTW: You picked the wrong place to complain about .NET, we can really see the vast improvements and we really like the changes.

Orbity
 
sorry i didnt give much detail


ok i got splash screen working


Splash screen

scenario 1


splash form as startup object


splash form starts

timer starts




timer tick



timer.stop
dim mainform as new frmmain
mainform.showdialog
me.close


everthing seems fine, but i realise the splash form isnt closed


and i cant hide the mainform from the system tray wat happens is it exits the app :S




scenario 2


mainform as start up object


mainform loads


dim splash as new frmsplash
splash.showdialog




splash loads

timer load



timer tick



me.close



but in scenario 2 i dont want to see the mainform yet i want the splash screen only and then once the splash goes then the mainform can be shown


i added a me.hide in the mainform load

once the splash closes i have no idea how to show the mainform back i put this code

dim mainform as new frmmain
mainform.show


it keeps creating a new instance



i did a splash screen in vb6 b4

but not this much trouble because of this new instantiating **** ****






ok as for the font



i have the mainform it has a few controls


click on a menu item out comes a form with a button on it


user clicks on it font dialog opens they select font and once they click apply on the form the main forms font will be changes to the users selection

on the apply button i put


dim mainform as new frmmain


mainform.font = fntdlg.font


doesnt work
doesnt change font and creates a new instance



i hope u have a way of solving it


is it really the only way to talk to a form
is to instantiate it?

gees

[edit]Please watch the language[/edit]
 
Last edited by a moderator:
As I pointed out in the quote from MSDN you need to create a new font object to change the font of a control, so here is the working and tested code to change the font of a form by clicking a command button named "Button1" and using a FontDialog named fdlFont.
Visual Basic:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    fdlFont.ShowDialog(Me)
    Me.Font = New Font(fdlFont.Font, fdlFont.Font.Style)
End Sub
I don't have time right now for the Splash screen stuff but someone else will help you I'm sure.

Orbity
 
Ok so I found a few minutes to make up a quick example which uses the main form as the startup object. Have a look at it and see if it helps. There is a 5 second delay on the splash screen.

Orbity
 

Attachments

Last edited by a moderator:
hmm its weird i applied it into my program
didnt just show the splash first..

it showed the splash and the mainform

i dont wanna see the mainform until the splash is gone


edit/ well i figured out why

it was becoz the windows state was to maximise on mainform load

but that still shouldnt effect it
 
Just change it to normal in the properties window (design view) and then in the form load change it to the following:
Visual Basic:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Dim frm As New Splash()
    frm.ShowDialog(Me)
    Me.WindowState = FormWindowState.Maximized
End Sub
That did the trick for me.

Orbity
 
omg u life saver
finally out of 2 days of asking

we got one thing fixed... now
i fink i need to work on the font form which is still a unsolvable matter although it looks soo simple


thanks for ur help dude!!
 
Winston said:
omg u life saver
finally out of 2 days of asking

we got one thing fixed... now
i fink i need to work on the font form which is still a unsolvable matter although it looks soo simple


thanks for ur help dude!!

I gave you the code for the font thing already. I just put the code I gave you into a blank project and here it is working and all. There is a label and a link label on the form as well as the command button just to show you what happens when you change the font of the form. Have a look and see if it helps.

Orbity
 

Attachments

Last edited by a moderator:
Oh no no... u got a little mixed up in the font idea

i know how to change it obviously
but the thing is...


Mainform> click a menu>navigate to font



a New form opens up this form is the font form

in it has a preview label and font name label and browse button

the user clicks on the browse button and they select the font
once selected they get a preview of wat it looks like and wats the name of the font


and wen they feel like it

they click apply


and the only part im stuck on is the apply code



the rest i know how to do...


i did this


dim mainas new frmmain

main.font = New Font(fdlFont.Font, fdlFont.Font.Style)


but wat happens is it keeps creating new instance of main form
and doesnt change font
 
Of course it does, you're explicitly creating a new instance. In some other thread I told you what to do to get around this. If you can't manage this, it's you're fault and not vb.net's. Orbity has been incredibly generous writing code to help you.

I suggest hitting the books and/or documentation for a few days. Buy a VB.NET book and read it from cover to cover.

Oh, and we don't do homework. You mentioned this was for your major assignment.
 
Last edited:
Back
Top