|
Uhhh... Why are you passing the LineOut array to the AddError function and AT THE SAME TIME using it to store a return from the very same function? You're AddError function should not be returning data to the same variable using two different methods at the same time.
I have no idea what your trying to do here, but this is approximately what your AddError might look like:
Friend Function LineCheck(ByVal LineIn As Line) As Line()
Dim LineOut() As Line
If LineIn.Field1 = "" Then AddError(LineIn, "Field1 Blank", LineOut)
If LineIn.Field2 = "" Then AddError(LineIn, "Field2 Blank", LineOut)
If LineIn.Field3 = "" Then AddError(LineIn, "Field3 Blank", LineOut)
If LineIn.Field4 = "" Then AddError(LineIn, "Field4 Blank", LineOut)
Return LineOut
End Function
Friend Sub AddError(ByVal LineIn As Line, ByVal LineError As String, ByRef LineOut() As Line)
Dim tmp As New Line
tmp = LineIn
tmp.LineError = LineError
If Not LineOut Is Nothing Then ReDim Preserve LineOut(LineOut.Length) Else ReDim Preserve LineOut(0)
LineOut(LineOut.Length - 1) = New Line
LineOut(LineOut.Length - 1) = tmp
End Sub
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I have an application that reads a file out of a phone and has a large string of hex data. I convert that data to ascii using the CHR command and am able to make a jpeg file and view what the picture is.
The problem I am having is that on systems that use asian language packs, the CHR function is incorrectly converting my data I think due to DBCS.
What I am looking for is a way to convert the hex data string I have to ascii that is universal and system independant.
Any idea out there? Thanks very much.
Jim Theisen
|
|
|
|
|
Since your code is getting the hex data completely unencoded, you'll have to detect for the existance of double byte characters yourself. Then provide alternate conversion code to handle this situation.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi all,
I am trying to fix teh col width of my datagrid but I get an error
@ dbgrd.GridColumnStyles(0).Width = 50
The error Msg is :
An unhadled exception of type 'System.ArgumentOutOfRangeEception'
Occured in mscorlib.dll.
Addional Information: Index was out of range. Must be non negative and less than the size of the collection.
Code:
With ds.Tables("Ord1")
Dim iCount As Integer
Dim nRow As Data.DataRow
For iCount = 0 To .Rows.Count - 1
nRow = objDT.NewRow()
nRow(0) = CType(.Rows(iCount).Item(0), String)
nRow(1) = CType(.Rows(iCount).Item(1), String)
nRow(2) = CType(.Rows.Item(iCount).Item(2), Long)
objDT.Rows.Add(nRow)
Next
Dim dbgrd1 As DataGridTableStyle = New DataGridTableStyle()
dbGrid1.DataSource = objDT
dbGrid1.ReadOnly = True
Dim dbgrd As DataGridTableStyle = New DataGridTableStyle()
dbgrd.MappingName = "Ord1"
dbGrid1.TableStyles.Add(dbgrd)
dbgrd.GridColumnStyles(0).Width = 50
dbgrd.GridColumnStyles(1).Width = 500
dbgrd.GridColumnStyles(2).Width = 500
can some one help.
Tnx
|
|
|
|
|
hi paps,
you're not actually instantiating any GridColumnStyles in your code. you're just trying to set the width of empty array elements. (GridColumnStyles(0), GridColumnStyles(1), GridColumnStyles(2) etc.) this is the raeson for the exception.
you can try doing this with the vs.net designer as well. just look at the TableStyles property of the datagrid from the properties window. you can set this up so that it's created in the initialization routine of the form rather than manually writing the code for it. take advantage of the code generation module and save yourself a case of carpal tunnels syndrome.
hope this helps.
-jim
|
|
|
|
|
|
When I set the prefered col width to 200 all the other columns too take the same width.
How do I specify the 2nd col with a different width.
Tnx
|
|
|
|
|
hi paps,
the preferred width property is on the tablestyle object. this will set the width of any columnstyle in the tablestyles gridcolumnstyles property that has a width value of 0.
if you set the width property of the columnstyle, the width of that column will be set accordingly.
hope this helps.
-jim
|
|
|
|
|
hi paps,
the gridcolumnstyles property belongs to the tablestyles property of the datagrid. so if you are doing this through the designer, have a look at the properties of the datagrid, find the tablestyles property and click the ellipsis button [...]. this should open the tablestyles editor dialog. next look for the columnstyles property in this dialog and click the ellipis button. this will open the columnstyles editor.
hope this helps.
-jim
|
|
|
|
|
I have the following code:
Dim dlgColorPicker As New frmColorPicker
dlgColorPicker.Show vbModal
Is there a way to get a value returned from the dialog? I want to know if the user pressed OK or Cancel. I know I can setup a global variable in frmColorPicker. Is this the only way?
Thanks,
Tim
|
|
|
|
|
I found some slick code to accomplish this:
Calling module:
[code]
Dim dlgColorPicker As New frmColorPicker
Dim iRet as VbMsgBoxResult
iRet = dlgColorPicker.ShowForm
[/code]
In frmColorPicker:
[code]
Private m_ReturnVal as VbMsgBoxResult
Public Function ShowForm() As VbMsgBoxResult
Me.Show vbModal
ShowForm = m_ReturnVal
End Function
Private Sub cmdOK_Click()
m_ReturnVal = vbOK
End Sub
Private Sub cmdCancel_Click()
m_ReturnVal = vbCancel
End Sub
[/code]
|
|
|
|
|
How can I do this?
For example: let's say on form1.vb, i have the following code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
product_code = TextBox1.Text.Substring(0, 4)
'switch over to next window
Dim form2 As New form2
form2.Show()
Endsub
Now, how can I get the value in product_code in Form2.vb ?
|
|
|
|
|
I was told by the mods that this forum is primarly .Net intended, and so I feel compelled to think that you are trying to do this with it, but just in case this hasn't changed since VB6 or you are indeed doing it in VB6, this is (or should I say was) the way to do it:
Declare the variable product_code on a separate .bas 'Module' object, with the Public word, insted of the good ol' 'Dim':
Public product_code As String
in this way you can access product_code from whereever in your project (different Subs, on different Forms, Modules, Class Modules, whatever!)
Hope that helps (and that you ARE doing it in VB6!)
Cheers,
Pablo.ar
|
|
|
|
|
Pablo,
Sorry, I should have clarified. Yes, I am attempting this in vb.net.
I am just starting in programming in .net, with no experience in vb6.
I did try declaring as Public, but with no luck. I'm sure there's a way of declaring variables globally so that this is possible.
By the way, I'm not sure what a .bas module object is. Is this vb6 terminology.
Thanks again for your help,
Mike
|
|
|
|
|
There's no such thing as a "global" variable in the .NET Framework. This goes for every language that targets .NET, not just VB.
The best way to do it is not to share a variable in the form, but to emulate the method Pablo mentioned. For an example of how to do this, check out Working with Multiple Forms in Visual Basic .NET: Upgrading to .NET[^] on MSDN.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
hi, looks to me like you're using .net based on the "handles" keyword in your method signature as well as a few other things, so i'll suggest another way for you. (no offense intended pablo! )
the best way to do this would be to set up a friend property on form1 one that gives access to a module level variable in form1. you'll also need a reference to the actual form1 object in form2. some thing like this...
public class form1
inherits system.windows.forms.form
'initialization code
private m_productCode as String
friend property ProductCode() as String
Get
return me.m_productCode
End Get
Set(byval value as string)
me.m_productcode = value
End Set
end property
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
me.ProductCode = textbox1.text.substring(0, 4)
dim frmTwo as new form2
frmTwo.FormOne = me
frmTwo.Show
end sub
end class
*'--- in a separate code file ---'*
class form2
Inherits System.Windows.Forms.Form
private m_formOne as Windows.Forms.Form
Friend Property Form1 as Windows.Forms.Form
Get
return me.m_formOne
End Get
Set(byval value as Windows.Forms.Form)
me.m_formOne = value
End Set
End Property
Private Sub form2_Load(byval sender as object, byval e as system.eventargs) handles form2.Load
'--- this line gives you access to the product code from form1 ---'
dim productCode as string = me.FormOne.ProductCode
End Sub
end class
the freind property in form2 gives form1 access to safely set a field in form2, and vice versa for the friend property in form1.
this code isn't tested and wasn't typed into my editor, so beware of syntaxtual errors. just a warning...
hope this helps
-jim
|
|
|
|
|
yeah, I guess I should've noticed that .Substring thingy and all the args on the event... it passed me by, sorry.
One more idea... do forms still have that .tag property? That was an amazingly useful property, which I worked with many many times!
Pablo.ar
PS: I feel old, hehe.
|
|
|
|
|
sure do.
-jim
|
|
|
|
|
i need to create vbscript code for detect all shared folders in a windows 2k/xp computer ... and remove those shared folders...
any help?
thanks in advanced
tutank
|
|
|
|
|
Imagine a listview with only one column.
I would like to place an existing *.jpg or *.bmp at the place of an item and in the item below text associating the picture.
The LargeIcon View with ImageList is nearly perfect, but the icons are too small for my pictures.
I have the idea to place picturboxes at the place of the items, but how. It must be at runtime.
I could also make a datagrid if this works easier.
Please give me some code example.
Thanks
|
|
|
|
|
Hi,
I have developed one application using Vb6.0. The application will use my custom dlls. I made installation package using Microsoft Package and deployment wizard, it was running perfectly. If the client wants some changes then i will do modifications on the custom dlls and compile the dlls. one moretime i will make the installation package with the revised dlls. Like this i made lot of versions on my application.
Now i installed .net, i made slight modifications just commented a message box on the dll code and compiled. I verified with the application without making package, it run perfectly. I made package, and run on the same machine, Now i am getting the Runtime error 430, whenever my application is try to run functions on the dll.
I refered the MSDN, they given the solution to unregister the dll and register manually. I did but then also i am getting the same error.
Then I upgraded by latest MDAC_TYP.EXE, then also i am getting the same error.
Please help me to comeout of this problem past 10 days i was not able to do anything.
Sathiyanarayanan.Ramanathan
|
|
|
|
|
Hi sathiyaram,
First thing to check:
Do you compile your VB6 DLL project with Binary compatibility and maintain compatibility between the different version? Project compatibility is the default, which will cause new GUIDs to be created each time you compile the DLL. Existing COM clients will break, unless you either repoint their references to the new version of the DLL or compile them together (in a project group).
Also, look up Binary compatibility in VB6, GUIDs, class IDs, interfaces IDs, etc. to learn more about this process.
I hope this helps you and/or points you in the right direction.
Pete
|
|
|
|
|
Hi Pete,
Thanks for your suggestion.
Initially my VB6 DLL Project was with Project Compatibility. After getting this error , i referred the MSDN and changed VB6 DLL Project to Binary Compatibility, then also I am getting the same error.
The setup.exe was created using microsoft Package & Deployment wizard for my application. Before installing the setup.exe, in development version the application is running without any problem at all with the modified DLL.
The error is particularly arising, after installing the application using setup.exe. I tried with various combination of including MDAC_typ.exe different version. Then also no improvement.
I found one thing that after installing my Application,if i unregister the dll in system dir and register again the dll manually using regsvr32, it is working fine. If i uninstall my application and again i reinstall the same story is repeating. I have to provide the application to my client.
Please suggest me how to verify compatibility on GUIDs,Class IDs, etc., because i haven't worked on system level.
With Regards
Sathiyanarayanan
|
|
|
|
|
Hi Sathiyanarayanan,
Unregister all previous versions of your DLL on your development box.
Turn binary compatibility off for now.
Put your VB6 app and DLL in a project group.
Compile that (do a full build).
Copy the DLL created to a sub-directory of your project directory, called "Reference"
Set binary compatibility on your project, pointing to the DLL in the "Reference" directory. This is your reference. Do NOT do subsequent compiles to this directory. Whenever you release a new version of this DLL, place it into the "Reference" folder. This now becomes your new reference. This ensures you don't lose compatibility from version to version of your DLL. Basically, this DLL in the "Reference" folder is only there to maintain the specific interface, class and programmatic IDs for the DLL, so they don't change from build to build and version to version (for existing interfaces).
Then, build the setup package and try installing on a clean machine without any previous instances of your DLL.
The topic of GUIDs, Class IDs, Interface IDs, etc., is very large. You could look at the VB6 project file to see what the GUID is for the DLLs you are referencing. You can view the COM interface(s) a DLL exports with a tool called "Depends.exe", installed with the rest of the Visual Studio tools. I can only give you general pointers in this area, as you will have to do a lot of research on your own to learn about this. Any book or website covering COM will be able to explain these topics in detail.
Good luck.
Pete
|
|
|
|
|
sathiyaram wrote:
I made installation package using Microsoft Package and deployment wizard
I think Microsoft Package and Deployment wizard is not the professional application to build setup project. Try to use InstallShield[^] to package your application.
Good luck
A thousand mile of journey, begin with the first step.
APO-CEDC
Save Children Norway-Cambodia Office
|
|
|
|
|