PDA

View Full Version : VB Doubt ?


Dipen01
19-08-2005, 08:56 PM
hi there...

Got a little doubt on VB here...

these codes may be syntactically incorrect. ignore syntax

1) -

Code 1)

form_load
print "Hello"
End Sub

Code 2)

form_load
Text1.text = "Hello"
End Sub


Though both the cases seem alike.. the message is not displayed (neither in frame or window) in first case whereas it displaying properly in case 2 as am using Text Box . Why ??


2) -

There are two text boxes. i want to shift the cursor from first text box to other or u can say focus from first one to other.. i wrote the code

form_load
text2.setfocus
End Sub

It shows some error. i cant remember that. i know there may be different methods to shift the focus but why its now working by this method.

siriusb
19-08-2005, 10:20 PM
In case 1, u need to set the AutoRedraw of the form to True.

2. Prolly the textbox object is not yet drawn at this stage. So put ur code inside form_activate.

bharat_r
19-08-2005, 10:24 PM
form_load
print "Hello"
End Sub

Yes ,it does not work for me too.I works if the print command is given to a command button ...Eg:
Private Sub Command1_Click()
Print "hello"
End Sub
If u need some text to be displayed as when the form is loaded ,u can use a Label Box & manipulate is visible properties.

form_load
text2.setfocus
End Sub

It does not work.It gives Run time error "5"
You can use this code to set the focus to textbox 2 when the form is loaded:
Private Sub Form_Load()
Text2.TabIndex = 0
End Sub

bharat_r
19-08-2005, 10:27 PM
sorry I did not see siriusb's post.
If his methord works ignore mine.

Dipen01
20-08-2005, 11:36 AM
In case 1, u need to set the AutoRedraw of the form to True.


thanx.. but whats the reason for keeping Autoredraw true..

2. Prolly the textbox object is not yet drawn at this stage. So put ur code inside form_activate.

but if somebody asks me the reason that why its not working thru form_load what shuld i tell ?? (in fact this is my assignment to give proper explanation on these)...

siriusb
20-08-2005, 02:35 PM
If it's ur assignment, go google or msdn urself.

Dipen01
20-08-2005, 03:27 PM
lolzz...was trying MSDN since last one hour..couldnt find a solid reason why ??....and google.. well i dont think i ll be able to find a reason on google...

anyways.. its ok..

Dipen

siriusb
20-08-2005, 04:07 PM
Well, if u hadn't figured it out yet, you may want to learn WHEN windows (controls and forms) are painted, that is to say, the the text and lines that make the control appear the way it does. You would better understand this concept when u learn windows programming in c++.
Right now, leave drawing of controls. Whenever a part of the window is covered by another window, then the covered window is not drawn untill it is exposed. This drawing and redrawing of the window won't happen unless u specify with the autoredraw property. Try printing onto any control with a visible hdc property with autoredraw disabled and cover part of the printed text with another window and then move it away.

For form_load, this too requires understanding a bit of windows programming. Every window is created in memory as some structure and then painted later onto the screen. When the form_load is being executed, the form (and its child controls) does not yet exist. So u cannot do a setfocus method call on it.
Also, form_load is called only once in a form's lifetime, whereas form_activate is called everytime you call form.show() method and the first time the form is loaded.

Dipen01
21-08-2005, 10:40 PM
hey buddy...

thanx.. a lot... certainly enlightened....


Dipen

Dipen01
21-08-2005, 10:44 PM
hey buddy...

thanx.. a lot... certainly enlightened....

well one thing... just went to bookstore to purchase a book on VB i had 3 options.. on was Mastering VB(Microsoft),VB Bible(cant remember),one book of Princeton..and one called VB black book...

VB black book looked good.. even asked him which one has greater sale.. he even agreed VB black book...

have u ever heard of this book... though contents are good.. but i hope am not missing anything... anyways..

whats the difference betn VB and VB .net or Java or Java.net ...or in short...why and what is this .net

Dipen

nirubhai
22-08-2005, 02:51 AM
Mastering VB is good for u

Java.net :shock: ..... no such language....

VB is VB 6.0
VB.net is VB 7.0

.net is microsoft's new platform. any lang that uses it can be said as <language>.net
e.g. ASP.net

siriusb
22-08-2005, 08:07 AM
Get the black book coz i think it goes deeper into vb than the others.

Hmmm... .net is a new framework from microsoft. You can imagine a framework to be a collection of APIs. Any language that uses these apis to for programming can be called a .net language.
Basically, .net languages are almost similar in logic (steps taken to accomplish a functionality) but differ in syntax. Since syntax is easily learnt, .net languages look almost the same to a programmer. Also, if u are a vb programmer, u can use vb.net. If for some wierd reason u like vc++, u can use vc++.net. There won't be any perf difference among the .net languages, since they all get compiled into a common lang runtime before execution. So it is flexible and progsrammers need not chose one language once .net platform is to be used.

Hope i primed u in on .net. Check the .net framework books for more.

Dipen01
22-08-2005, 12:46 PM
Sure... thanx a lot...

u said VC++ a wierd lang... dont we need VC++ anywhere nowadays.. i mean are its substitutes available...