|
This still won't work. Your comparing an Enum value to itself which will ALWAYS return TRUE!!
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
ok thanks for the message box help
So how do i get the "no" button to do a different procedure?
for it i have
MsgBox("Message", MsgBoxStyle.YesNo)
If System.Windows.Forms.DialogResult.Yes = Windows.Forms.DialogResult.Yes Then
txtTotal.Text = CStr(rlMemory)
Form2.txtTotalCost.Text = CStr(rlMemory)
Form2.txtDiscount.Clear()
Form2.Show()
End If
for that variable thing i have
Dim intNights As Integer
Dim rlPrice As Single
Dim rlTotal As Single
Dim rlMemory As Single
basically rlMemory stores the data i need, but at the end of the program when u get a diaglog box giving you the option to restart the program, at this point i need the rlmemory to go back to 0.
-- modified at 16:40 Tuesday 17th October, 2006
|
|
|
|
|
Here is how you should do it:
<br />
Dim BoxCall As MsgBoxResult<br />
BoxCall = MsgBox("Message", MsgBoxStyle.YesNo)<br />
If BoxCall = MsgBoxResult.Yes Then<br />
If System.Windows.Forms.DialogResult.Yes = Windows.Forms.DialogResult.Yes Then<br />
txtTotal.Text = CStr(rlMemory)<br />
Form2.txtTotalCost.Text = CStr(rlMemory)<br />
Form2.txtDiscount.Clear()<br />
Form2.Show()<br />
Else<br />
'Code for "No" goes here. Leave blank if no procedure is needed.<br />
End If<br />
And you said that you want rlmemory to go to 0? If so, then use this:
rlmemory = "0" .
Hope this helps.
|
|
|
|
|
UltraCoder wrote: rlmemory = "0".
Assuming it is a string. I'd have assumed otherwise.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Have you noticed anything weird about the two if statements in the post you replied to?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
with the messagebox i have
Dim BoxCall As MsgBoxResult
BoxCall = MsgBox("Message", MsgBoxStyle.YesNo)
If BoxCall = MsgBoxResult.Yes Then
If System.Windows.Forms.DialogResult.Yes = Windows.Forms.DialogResult.Yes Then
txtTotal.Text = CStr(rlMemory)
Form2.txtTotalCost.Text = CStr(rlMemory)
Form2.txtDiscount.Clear()
Form2.Show()
Else
Form4.txtTotalCost.Text = CStr(rlMemory)
Form4.Show()
End If
End If
but form 4 doesnt show =z
well i tried using rlmemory = "0" but it doesnt reconise it as its on another form also i did have it in the form load but didnt seem to work if i wanted to re add something
Example of what program does
(working in down structure)
Menu (form)
calculation (form) <--input data \ calculate it
total (form) <-- takes final sum and has it on a new form with do u want to do calculation again
-- modified at 21:00 Tuesday 17th October, 2006
|
|
|
|
|
Ok, for one, remove "If System.Windows.Forms.DialogResult.Yes = Windows.Forms.DialogResult.Yes Then" and then the duplicate "End IF" at the bottom, (A small mistake on my part).
For the "No", use the same procedure as "Yes". Example:
<br />
If BoxCall = MsgBoxResult.No Then<br />
'Code Goes Here<br />
End If<br />
And as for clearing the "rlmemory" varible, try rlmemory = 0 , or if the varible is in another form, you might have to use something like a setting to hold the varible..
I hope this helps. If not, you could try posting the code for "rlmemory" (setting/removing values etc.)
|
|
|
|
|
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
|
|
|
|
|
I have tried this method and it does not work! The method I posted works fine!
|
|
|
|
|
It works because you only tested one case for your if statements. They ALWAYS return True because, in essence, you did this: If 2 = 2 Then ... .
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Thanks Dave, that was the attempt of my point.
Just because you leave off "system" doesn't tie the enum to the result of the msgbox. you need to test what the msgbox is returning.
nathan
|
|
|
|
|
Hi Members
I need some info regarding how to create a hotkey for application with combination of letters or numbers e.g Ctrl + 1234
Regards
|
|
|
|
|
Windows doesn't support such combinations. You have to use a single letter or number.
Now, if you were to write your own service, complete with a global keyboard hook, and tracking which keys were hit and released, then its possible.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Select the "ShortcutKeys" option in the Control's properties. From there you can change the ShortcutKeys. Doing so by code doesn't work right.
|
|
|
|
|
Nice, but it won't work with multiple keys in the combination. Only one key is allowed - Ctrl-A, Ctrl-5 - not Ctrl-123 or Ctrl-A3b.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I have created a folder for a specific location in vb.net but I want to automatically generate the folder name as the current date when it is created. If anyone know any code to do this please let me know ASAP. Thanks!
jds1207
|
|
|
|
|
Well, to name the directory for the current date, then try this:
<br />
Dim DirName As String = "C:\" + DateTime.Today<br />
My.Computer.FileSystem.CreateDirectory(DirName)<br />
Or, to name directory for the current date and time, try this:
<br />
Dim DirName As String = "C:\" + My.Computer.Clock.LocalTime<br />
My.Computer.FileSystem.CreateDirectory(DirName)<br />
|
|
|
|
|
Converting a Date to a string is very easy. All you have to do is supply a format string to the ToString() method and you've got your directory name.
Dim dirName As String = DateTime.Now.ToString("MM-dd-yyyy")
Then you just combine that with the parent path the you want to create that directory in:
Imports System.Io
.
.
.
Dim fullPath As String = Path.Combine(Application.StartupPath, dirName)
Directory.CreateDirectory(fullPath)
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Thank you very much! Now how do you add the time to the name also?
|
|
|
|
|
Just use:
<br />
Dim dirName As String = DateTime.Now.ToString("M-d-yyyy hh.mm.ss tt")<br />
or without am/pm:
<br />
Dim dirName As String = DateTime.Now.ToString("M-d-yyyy hh.mm.ss")<br />
-- modified at 2:38 Wednesday 18th October, 2006
|
|
|
|
|
Whoa there! You better start thinking before you start posting code. Slashes and colons are not legal in file or directory names.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Funny, this was in the Visual Basic Studio Help File. Maybe Microsoft ought to think before the write a help file!
|
|
|
|
|
Yes, it is documented, you just have to read it first. It's in the documentation for DOS, Windows, Visual Studio, and the .NET Framework. It's also found by a examination of fully qualified filepaths too. How about launching a program with a path like this:
C:\WINDOWS\NOTEPAD.EXE /P MYFILE.TXT
You'll note the colon seperates the drive letter from the rest of the path. The backslash seperates folder and file names. And the forward slash is reserved for specifying command line parameters.
Under the .NET Framework 1.x, the invalid characters are returned by Path.InvalidPathChars[^]. Under 2.0, that functionality has been split between two methods: Path.GetInvalidFileNameChars[^] and GetInvalidPathChars[^].
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Change the format string to any combination you want.
"yyyy-MM-dd hh.mm.ss"
Remember, slashes and colons are not legal in filenames.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
This is the code, i can't preview the second pages on print preview,i reach the first page last line and the following data should be preview on second page..but the data preview on the 1st page and cover the 1st layer's data,Please help..project deadline around..thanks
If TotalRecord - 1 <> Counts - 1 Then
For i As Integer = 0 To Counts - 1 Step 1
If EOF = True Then
With e.Graphics
.DrawString("SAFEBANK", drawFontTitle, drawBrush, 450.0F, 50.0F, StrFormatCenter)
.DrawString(Now.Date, drawFont, drawBrush, e.MarginBounds.Right - 50, 50.0F, StrFormatCenter)
.DrawString("Tel No.:XXX-XXXXXXXX", drawFontTitle, drawBrush, 450.0F, 80.0F, StrFormatCenter)
.DrawString("Fax No.:XXX-XXXXXXXX", drawFontTitle, drawBrush, 450.0F, 110.0F, StrFormatCenter)
.DrawLine(mypen, 90.0F, 150.0F, 750.0F, 150.0F)
.DrawString("TransID", drawFont, drawBrush, 50.0F, 170.0F, StrFormatLeft)
.DrawString("TransTime", drawFont, drawBrush, 130.0F, 170.0F, StrFormatLeft)
.DrawString("Amount RM", drawFont, drawBrush, 280.0F, 170.0F, StrFormatLeft)
.DrawString("AC number", drawFont, drawBrush, 420.0F, 170.0F, StrFormatLeft)
.DrawString("AC number", drawFont, drawBrush, 540.0F, 170.0F, StrFormatLeft)
.DrawString("Server", drawFont, drawBrush, 680.0F, 170.0F, StrFormatLeft)
yPos = 170.0F + Count * drawFont.GetHeight
.DrawString(TransID(i), drawFont, drawBrush, 50.0F, yPos, StrFormatLeft)
.DrawString(TransTime(i), drawFont, drawBrush, 130.0F, yPos, StrFormatLeft)
.DrawString(Amount(i), drawFont, drawBrush, 280.0F, yPos, StrFormatLeft)
.DrawString(Acc1(i), drawFont, drawBrush, 420.0F, yPos, StrFormatLeft)
.DrawString(Acc2(i), drawFont, drawBrush, 540.0F, yPos, StrFormatLeft)
.DrawString(Server(i), drawFont, drawBrush, 680.0F, yPos, StrFormatLeft)
Count += 1
TotalRecord += 1
EOF = False
End With
Else
yPos = 170 + Count * drawFont.GetHeight
With e.Graphics
.DrawString(TransID(i), drawFont, drawBrush, 50.0F, yPos, StrFormatLeft)
.DrawString(TransTime(i), drawFont, drawBrush, 130.0F, yPos, StrFormatLeft)
.DrawString(Amount(i), drawFont, drawBrush, 280.0F, yPos, StrFormatLeft)
.DrawString(Acc1(i), drawFont, drawBrush, 420.0F, yPos, StrFormatLeft)
.DrawString(Acc2(i), drawFont, drawBrush, 540.0F, yPos, StrFormatLeft)
.DrawString(Server(i), drawFont, drawBrush, 680.0F, yPos, StrFormatLeft)
Count += 1
TotalRecord += 1
End With
End If
If Count = LastRecord Then
e.HasMorePages = False
Count = 0
EOF = True
Else
e.HasMorePages = True
End If
Next
End If
From
Daryl
|
|
|
|
|