|
You need to remember a reference to formA in formB and in Form_Unload you can call some methods by using this reference. Good method for implementing this is some kind of control, which is placed on all forms of your app.
|
|
|
|
|
hi,
I set up a dummy project, two buttons on form A and a button and a text box on form B,
load form A press button 1, form B is shown, fill some text in the text box
press the button on form B, form B is hidden.
Then Press other button on form A to show msgbox of text in box on form B.
Lovely Jubbly
Form A code:
Private Sub Command1_Click()
Load Form2
Form2.Show
End Sub
Private Sub Command2_Click()
MsgBox Form2.txtMsg.Text
End Sub
Form B Code:
Private Sub Command1_Click()
Form2.Hide
End Sub
"If i was king cigarettes would be free."
|
|
|
|
|
What about having two forms A (in MDI App) with different data? Which one will be called?
|
|
|
|
|
First off, I have found some articles on the MSDN website that have pointed me in the right direction but don't have all the answers. Also, I am using Visual Basic 6.0.
I need to be able to access a file and do a couple of things with it:
1) I need to find out if it exists and if not, then create it. I found
System.IO.File.Exists("c:\ExistingFileName")
but I get an error. I believe this error is due to the fact that I have not told the compiler I am using the system namespace. How do you signal the compiler you are using the System namespace in Basic?
In C it would be using System.IO.File, but I have no clue in Basic.
2) What is the command to create a sequential file in Basic and what variable will I have access to?
3) How do I add to it/ close it when I am done?
Thank you,
Zach Calvert
-----------------
http://www.zachcalvert.com
|
|
|
|
|
here a sample
http://www.andreavb.com/forum/news/viewtopic.php?TopicID=1485
|
|
|
|
|
it doesn't use the system namespace. I am using this for a school project and I must use the system namespace. Also, it only reports error codes. I need to be able to check to see if it exists, not catch errors.
-----------------
http://www.zachcalvert.com
|
|
|
|
|
The System.IO namespace contains the File class. This class contains the shared .Exists method you use to check to see if the filename exists, prefferable using the FULL PATH to the file. .Exists isn't documented to throw any exceptions. It just returns True or False .
In a normal installation of Visual Studio .NET or Visual Basic.NET, the System namespace is automatically imported into your project. You don't have to use the Imports System statement at the top of your code because it's already done behind the scenes. You DO, on the other hand, have to put in the Imports System.IO yourself, again, at the top of your code.
Imports System.IO
Public Class Form1
.
.
.
Private Sub WhatEver()
' You don't nedd to specify the System.IO namespace prefix because you
' already Imported it at the top of your code.
If File.Exists("C:\myTestFile.txt") Then
.
.
.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I'm using VB 6.0, and it doesn't let me do Imports System.IO
What do I do now?
-----------------
http://www.zachcalvert.com
|
|
|
|
|
OK. Then throw out EVERYTHING about namespaces and System , System.IO , File.Exists ... EVERYTHING. VB.NET is a VERY different language from VB6 and none of this stuff applies to VB6.
Now, you'll have to use the FileSystemObject to see if the specified file exists. This will return either True or False , it doesn't throw any errors.
Set fs = CreateObject("Scripting.FileSystemObject")
If fs.FileExists("C:\myTestFile.txt") Then
.
. ' The file exists...
.
Else
.
. ' The file doesn't exist...
.
End If
To open a text file for sequential write, you'll use the Open statement (docs here[^]):
Open "C:\myTestFile.txt" For Output As #1
Print #1, "This is line 1"
Print #1, "This is line 2..."
Print #1, "This is line 3..."
Close #1
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi VB Gurus,
I have a Command line application in Visual Basic(it is a simple VB program without any form having a 'Sub Main'). Can anybody tell me how to return an integer from this application to the calling program.
Thanks in advance,
Jobby
|
|
|
|
|
VB6 and below doesn't support returning an exit code to the calling process (a.k.a. setting the ERRORLEVEL). But, it can be done using the ExitProcess API. You can find the simple code and example here[^].
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
|
I have code that populates a dropdownlist control from a dataset. The dataset has two fields; one I assign to 'text' and one to 'value'. This all works great. My pull down list functionality works as advertised. PROBLEM is when I open the page, I populate all the controls with the value from the record that the page is displaying...The ddl value is assigned to the control in the code which loads the contols (witnessed by stepping throught the code, but the value that gets displayed in the Dropdownlist is always the 0 index item (first one in the dataset) and not the value assigned to it in the code assignments of the data record. I have tried assigning the value from the data table to a variable and then 'findbyvalue = to that variable', but no luck. I have searched the high seas for references to the use of the ddl, which funny enough seems to be elusive. For such a valuable/oft used control,in VB GUI, I would hope to find something that addresses the full use of the control . I mean 4GuysFromRolla did a million part series on the datagrid, but not even a page on the ddl? can anyone help me ?
I am getting my dataset from the global asa and populating the ddl
If Not IsPostBack Then
dsCBO = Application.Get("dsPhysCBO")
Me.ddlPMD.DataSource = dsCBO
Me.ddlPMD.DataTextField = "PhysLast"
Me.ddlPMD.DataValueField = "PUID"
Me.ddlPMD.DataBind()
no problem!
I get a datareader to populate the fields on the form and assign the stored value to the ddl
Me.ddlPMD.SelectedItem.Value = reader("PriMD").ToString
At this point (stepping through the code) value="PriMD"
still no problem.
I try to place the index of the ddl to the value passed in using a variable populated with "PriMD" a string myKey2
Me.ddlPMD.Items.FindByValue(myKey2.ToString).Selected = True
When the page displays...the text displayed in the ddl is that for the first item in the ddl dataset, not the text corresponding to the value of myKey2
Where do I error???
JR
|
|
|
|
|
Try this:
Dim i As Long
Dim iList As ListItem
either
iList = ddlContacts.Items.FindByText("Dave")
or
ilist = ddlContacts.items.FindByValue(3)
i = ddlContacts.Items.IndexOf(iList)
ddlContacts.SelectedIndex = i
That'll work
"If i was king cigarettes would be free."
|
|
|
|
|
Thanks for the response.
When I used the ddl and added items to the collection in the properties page I had no problems which only added to the confusion in trying to bring a value out of the ds and display the corresponding row in the ddl. So that I understand....
When I was using the findbyvalue or findbytext...I was 'probably' finding...but not setting the selectedindex to the indexof the 'found' row ? And I will presume that a variable of string, or long, can be inserted as the object of findbytext, or findbyvalue ?
I will try it later this afternoon...and when it works, even though I am a non smoker, you would have my vote for KING!
|
|
|
|
|
hi
i have created a calendar application which shows each day that has an appointment on it, but im having trouble printing the days which are hidden behind a scroll bar.
The user is suppose to be able to print the number of days which they specify and some days may not be shown on the screen.
I can print the screen but not anything behind a scroll bar.
any ideas or suggestions would be very much appreciated
thank you
vinesh
|
|
|
|
|
I am attempting to adjust the contrast/brightness of a 256 color, paletted bitmap in a VB PictureBox using the Windows API in VB 6.0. My first attempt was to change the palette using something like:
tempDC = CreateCompatibleDC(0&)
call SelectObject(tempDC, Picture1.Picture.Handle)
PaletteSize = GetDIBColorTable(tempDC, 0, 256, pal)
' Do stuff with the palette
Call SetDIBColorTable(tempDC, 0, 256, pal)
DeleteDC tempDC
That's just a basic outline of my code, not exact. Anyway, it worked but what I noticed was that if the user tried to readjust the brightness/contrast to the way it was before, the image did not look the same. An extreme case is when the user adjusts the brightness to as bright as it will go, thus producing just a white box. Upon trying to re-adjust to the default brightness, instead of the image the picturebox just displays a black box. It looks like changing the palette saturates some of the pixels, thus losing that information.
What I really need to do is take a device-independent bitmap created in VC++, and then somehow get that into VB and draw it on the picturebox. I also need to be able to adjust image brightness/contrast, but not permanently alter the image pixels in case the user wants to "undo" what they did. I've tried any number of Windows API calls to accomplish this, but to no avail. Right now, I am just writing the bitmap to file in C++, and loading it in VB like so:
Dim MyPic as StdPicture
Set MyPic = LoadPicture("the_image.bmp")
Then, when I need to display the image, I pass it to another function which calls PaintPicture on my PictureBox control:
Picture1.PaintPicture(MyPic, 0, 0, Width, Height, etc...)
I know there has to be a better way. How can I go from a set of pixels in VC++ to a device-dependent bitmap in VB that is adjustable and can have any adjustments performed on its palette "undone"? If somebody could give me some direction, that would be great! Thanks a lot.
Jason
|
|
|
|
|
have a look here:
http://www.vbaccelerator.com/home/VB/Code/vbMedia/Image_Processing/index.asp
|
|
|
|
|
Does anyone know what following error means:
Additional information: Unable to find an entry point named OCIEnvCreate in DLL oci.dll.
|
|
|
|
|
check this thread on dotnet247 about that problem.
http://www.dotnet247.com/247reference/msgs/19/99192.aspx
|
|
|
|
|
This may seem like a simple question, but I haven't been able to find an answer to it yet.
I'm writing a code parsing app that uses reflection to get the various types given referenced assemblies. I've located the assembly where all the basic data types (String, Boolean, Byte, etc.) are defined except Integer, Long, and Short data types. I've inspected mscorlib.dll and system.dll and didn't find them.
Does anyone know where these "types" are defined?
|
|
|
|
|
They are in mscorlib as well. Short, Integer, and Long are Visual Basic keywords that represent the types System.Int16, System.Int32, and System.Int64, respectively.
You can verify this easliy:
Dim t as Type = GetType(Long)
Console.WriteLine(t.Name) 'Prints Int64
Dim assem as [Assembly] = [Assembly].GetAssembly(t)
Console.WriteLine(assem.FullName) 'Prints mscorlib, Version=... etc.
Charlie
if(!curlies){ return; }
|
|
|
|
|
Thanks for your reply
I do know about the equivalancy of the data types, but I was wondering if the keywords were defined anywhere that I could read. For instance, I am wanting the user to be able to select from a data type combobox, and I would like to populate from the system assemblies...I know I can add these manually, but I'm not sure that Short, Integer, and Long are the only ones I am missing...these are the only obvious ones.
Anyway...thanks
|
|
|
|
|
Microsoft.VisualBasic.VbTypeName("System.Int32") 'Integer<br />
Microsoft.VisualBasic.SystemTypeName("Long") 'System.Int64
Charlie
if(!curlies){ return; }
|
|
|
|
|
|