VB Doubt ?

Status
Not open for further replies.

Dipen01

Youngling
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

Cyborg Agent
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

In the zone
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
 
OP
Dipen01

Dipen01

Youngling
siriusb said:
In case 1, u need to set the AutoRedraw of the form to True.


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

siriusb said:
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)...
 
OP
Dipen01

Dipen01

Youngling
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

Cyborg Agent
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.
 
OP
Dipen01

Dipen01

Youngling
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

Broken In
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

Cyborg Agent
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.
 
OP
Dipen01

Dipen01

Youngling
Sure... thanx a lot...

u said VC++ a wierd lang... dont we need VC++ anywhere nowadays.. i mean are its substitutes available...
 
Status
Not open for further replies.
Top Bottom