Click here to Skip to main content
16,005,162 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Few Questions " dialog box" " global variable" [modified] Pin
Dave Kreskowiak17-Oct-06 10:25
mveDave Kreskowiak17-Oct-06 10:25 
QuestionRe: Few Questions "dialog box""global variable" Pin
Ultima Reborn17-Oct-06 10:28
Ultima Reborn17-Oct-06 10:28 
AnswerRe: Few Questions "dialog box""global variable" Pin
UltraCoder17-Oct-06 10:56
UltraCoder17-Oct-06 10:56 
GeneralRe: Few Questions "dialog box""global variable" Pin
Christian Graus17-Oct-06 12:44
protectorChristian Graus17-Oct-06 12:44 
GeneralRe: Few Questions "dialog box""global variable" Pin
Dave Kreskowiak17-Oct-06 17:41
mveDave Kreskowiak17-Oct-06 17:41 
GeneralRe: Few Questions "dialog box""global variable" [modified] Pin
Ultima Reborn17-Oct-06 14:33
Ultima Reborn17-Oct-06 14:33 
GeneralRe: Few Questions "dialog box" global variable Pin
UltraCoder17-Oct-06 15:17
UltraCoder17-Oct-06 15:17 
AnswerRe: Few Questions " dialog box" " global variable" Pin
nlarson1117-Oct-06 17:19
nlarson1117-Oct-06 17:19 
Ultra,

1) Ultra coder seemingly is testing the same enum against itself which is not giving you your answer. System library is implied that's why you do not have to use the 'import' key word in most cases.

If MsgBox("text goes here", MsgBoxStyle.Question + MsgBoxStyle.YesNo + _
MsgBoxStyle.DefaultButton2,"form title") = MsgBoxResult.Yes Then
Dim oFrm as new Form2
oFrm.ShowDialog
oFrm.Dispose
oFrm = Nothing
Else
Close()
End If

2) Instead of telling you that it's a bad idea. no one seemingly answered your question. "how do i do a global variable". You do this by creating module file (old bas extension) and adding a public variable in there. Because a module is considered public by all files in your project, the variable is available from every piece of code.

Module basMain
public gsValue as string '<--- global variable
End Module

'now you can update or ask for the value of the variable anywhere

class form1
private sub ShowMeValue
msgbox gsValue
end sub
end class




3) You asked if you can update a variable of one form from another. There are a lot of methods that are not the most desirable but saying that "you can't" is not correct. Were there's a will there's a way. One way is to pass the pointer of the form1 into form2 via a routine.

class form1
public msVariable as string

private sub CallAnotherForm
Dim oFrm as new form2

ofrm.ExecuteMethod(me) '<---
ofrm.showdialog

ofrm.dispose
ofrm = nothing
end sub
End Class

class form2
public sub ExecuteMethod(oFrm as form1)
oFrm.msVariable="Hello" 'you just updated the variable of form1
End Sub
end class

Hope this helps...
Nathan
GeneralRe: Few Questions &quot; dialog box&quot; &quot; global variable&quot; Pin
UltraCoder17-Oct-06 20:35
UltraCoder17-Oct-06 20:35 
GeneralRe: Few Questions &quot; dialog box&quot; &quot; global variable&quot; Pin
Dave Kreskowiak18-Oct-06 1:41
mveDave Kreskowiak18-Oct-06 1:41 
GeneralRe: Few Questions &quot; dialog box&quot; &quot; global variable&quot; Pin
nlarson1118-Oct-06 3:19
nlarson1118-Oct-06 3:19 
Questionhow to create hotkey with combination of letters Pin
Ali 11017-Oct-06 5:39
Ali 11017-Oct-06 5:39 
AnswerRe: how to create hotkey with combination of letters Pin
Dave Kreskowiak17-Oct-06 6:05
mveDave Kreskowiak17-Oct-06 6:05 
AnswerRe: how to create hotkey with combination of letters Pin
UltraCoder17-Oct-06 8:04
UltraCoder17-Oct-06 8:04 
GeneralRe: how to create hotkey with combination of letters Pin
Dave Kreskowiak17-Oct-06 10:00
mveDave Kreskowiak17-Oct-06 10:00 
QuestionCreate folder with current date Pin
jds120717-Oct-06 5:15
jds120717-Oct-06 5:15 
AnswerRe: Create folder with current date Pin
UltraCoder17-Oct-06 8:12
UltraCoder17-Oct-06 8:12 
AnswerRe: Create folder with current date Pin
Dave Kreskowiak17-Oct-06 9:59
mveDave Kreskowiak17-Oct-06 9:59 
GeneralRe: Create folder with current date Pin
jds120717-Oct-06 11:01
jds120717-Oct-06 11:01 
GeneralRe: Create folder with current date [modified] Pin
UltraCoder17-Oct-06 15:26
UltraCoder17-Oct-06 15:26 
GeneralRe: Create folder with current date Pin
Dave Kreskowiak17-Oct-06 17:43
mveDave Kreskowiak17-Oct-06 17:43 
GeneralRe: Create folder with current date Pin
UltraCoder17-Oct-06 20:40
UltraCoder17-Oct-06 20:40 
GeneralRe: Create folder with current date Pin
Dave Kreskowiak18-Oct-06 1:38
mveDave Kreskowiak18-Oct-06 1:38 
GeneralRe: Create folder with current date Pin
Dave Kreskowiak17-Oct-06 17:45
mveDave Kreskowiak17-Oct-06 17:45 
QuestionPls help,Deadline around - Print preview problem(can't preview on second preview page) Pin
nightkid888517-Oct-06 4:48
nightkid888517-Oct-06 4:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.