Click here to Skip to main content
       

Visual Basic

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page  Show 
AnswerRe: How to convert vb.net application to work onlinememberDavid Mujica22 Jan '13 - 3:03 
Without knowing what your project does, it is hard to determine how to go about this..
 
Basically, you would need to develop a web page which collects the data and stores it in the database your already have configured.
 
It can be done. More details are needed. (Desccribe what data is collected and stored)
 
Good luck.
QuestionHow to Extend the InitializeComponents to my code in VB2008/2010memberQuickBooksDev20 Jan '13 - 3:06 
We have many VB2008/2010 programs converted from VB6.
 
They used the VB6 Control Arrays (which I really miss).
 
The VB.Net code uses VB6 compabitity control arrays which works well but hard to maintain if new control arrays are needs.
 
We have begun replacing these with List (of ..) and AddHander's which also works well.
 
What we would like is for our code to populate the list ofs and do the AddHandlers to be done when the InitializeComponent is done.
 
So how can we 'extend' the IntializeComponents to our code or have our code run after the InitializeComponents.
 
Thanks
AnswerRe: How to Extend the InitializeComponents to my code in VB2008/2010mvpEddy Vluggen21 Jan '13 - 3:31 
QuickBooksDev wrote:
So how can we 'extend' the IntializeComponents to our code or have our code run after the InitializeComponents.

The "best" way is to not modify the call; it's there for the designer, and anything in there is autogenerated (it will be overwritten, removing your modifications).
 
Add a virtual or abstract method to an empty form, and call it from the constructor. Next, inherit your forms from this new one.
Bastard Programmer from Hell Suspicious | :suss:
If you can't read my code, try converting it here[^]
They hate us for our freedom![^]

GeneralRe: How to Extend the InitializeComponents to my code in VB2008/2010memberQuickBooksDev21 Jan '13 - 5:28 
Modify what call.
 
I am looking for a way to invoke our 'DesignerExtensions' automatically. I know not to change the designer.
 
What is a Virtual or abstract method. What constructor? There are none what we have coded.
 
We have several programs with multiple forms that we need to do this on.
 
Can you please give concrete examples?
GeneralRe: How to Extend the InitializeComponents to my code in VB2008/2010mvpEddy Vluggen21 Jan '13 - 5:43 
QuickBooksDev wrote:
Modify what call.
"InitializeComponents". Don't modify it's contents.
 
QuickBooksDev wrote:
What is a Virtual or abstract method.
Aw, sorry for using C#-terminology; it's called "Overridable" in VB.NET.
 
QuickBooksDev wrote:
We have several programs with multiple forms that we need to do this on.

Can you please give concrete examples?
Take an empty form, and modify it like below;
Public Class BaseForm
    Sub New()
        ' This call is required by the designer.
        InitializeComponent()
 
        ' Add any initialization after the InitializeComponent() call.
        InitializeVB6Handlers()
    End Sub
 
    Public Overridable Sub InitializeVB6Handlers()
        System.Windows.Forms.MessageBox.Show("Boo!")
    End Sub
End Class
Next, change your existing form to Inherit from the BaseForm like below;
Public Class Form1 : Inherits BaseForm
End Class
This would give you a method that's called when the form is constructed (just like InitializeComponents), and give you the option to override it's implementation for a specific form;
Public Class Form1 : Inherits BaseForm
    Public Overrides Sub InitializeVB6Handlers()
        'MyBase.InitializeVB6Handlers()
        System.Windows.Forms.MessageBox.Show("No Boo today")
    End Sub
End Class
Bastard Programmer from Hell Suspicious | :suss:
If you can't read my code, try converting it here[^]
They hate us for our freedom![^]

GeneralRe: How to Extend the InitializeComponents to my code in VB2008/2010memberQuickBooksDev21 Jan '13 - 6:49 
Thanks will give it a try.
GeneralRe: How to Extend the InitializeComponents to my code in VB2008/2010memberQuickBooksDev22 Jan '13 - 0:21 
Seems to work.
 
Will start implementation.
 
Thanks
GeneralRe: How to Extend the InitializeComponents to my code in VB2008/2010mvpEddy Vluggen22 Jan '13 - 2:21 
You're welcome Smile | :)
AnswerRe: How to Extend the InitializeComponents to my code in VB2008/2010memberMike Meinz21 Jan '13 - 8:16 
I wonder why you wouldn't just call your customized initialization from within the Load event in your source code for each Windows Form. Doing so, you don't have to touch the Windows Form Designer generated code file (*.Designer.vb).
 
Or am I missing something?
GeneralRe: How to Extend the InitializeComponents to my code in VB2008/2010memberQuickBooksDev21 Jan '13 - 9:38 
We were.
 
But there are times when things need to be checked in various controls before the form is show or brought up. When this occurs the List ofs are not initialized (value of nothing).
 
With the VB6.compatibility for control arrays they were inititized in the designer so no problem.
 
Just looking to make it all work the way it was.
QuestionMS Graph in Access 2007 VBA Applicationmembersatcomengineer19 Jan '13 - 7:48 
I am attempting to include a Microsoft Graph control on a tab on a form in my Access 2007 application. I have given it a query as a Row Source. What else is required?
AnswerRe: MS Graph in Access 2007 VBA ApplicationmvpEddy Vluggen20 Jan '13 - 2:38 
The "type" of chart. Have a tutorial[^] Smile | :)
Bastard Programmer from Hell Suspicious | :suss:
If you can't read my code, try converting it here[^]
They hate us for our freedom![^]

Questionvb6.0memberBarun sengupta18 Jan '13 - 21:39 
How to Select .pdf file from a folder in to DriveListBox in vb6.0
AnswerRe: vb6.0mvpEddy Vluggen20 Jan '13 - 2:36 
Selecting an item in the UI? By clicking on it. There's some old documentation on the DriveListBox[^].
 
VB6 is a dead language; I strongly recommend upgrading to something more recent.
Bastard Programmer from Hell Suspicious | :suss:
If you can't read my code, try converting it here[^]
They hate us for our freedom![^]

QuestionDecoding USBSTOR Registry Entry in VBmemberSantLou4017 Jan '13 - 16:06 
Hi All,
 
I am attempting to retrieve USB Usage History using VB.NET. I am using VS 2012.
 
The following block of code lists this entry.
 
Dim RegKey As RegistryKey = Registry.LocalMachine.OpenSubKey("SYSTEM\CurrentControlSet\Enum\USBSTOR\", False)
 
Dim str1 As String
For Each subKeyName As String In RegKey.GetSubKeyNames()
 
    Dim tempKey As RegistryKey = RegKey.OpenSubKey(subKeyName)
    Debug.Print("USBSTORE KEY: " & subKeyName & RegKey.GetValue(subKeyName, "").ToString())
    Debug.Print(" -----------")
 
    For Each NxtSubKeyName As String In tempKey.GetSubKeyNames()
        Dim tempKey1 As RegistryKey = tempKey.OpenSubKey(NxtSubKeyName)
        Debug.Print("USBSTOR SUBKEY: " & NxtSubKeyName.ToString() & " Value Count: " & tempKey1.ValueCount.ToString())
        For Each valueName As String In tempKey1.GetValueNames()
            Debug.Print(valueName & ": " & tempKey1.GetValue(valueName).ToString())
        Next
 
    Next
Next
 
My code produces this output:
 
USBSTORE KEY: Disk&Ven_SanDisk&Prod_Cruzer&Rev_1100
 -----------
USBSTOR SUBKEY: SDXX1005181106121551&0 Value Count: 12
DeviceDesc: @disk.inf,%disk_devdesc%;Disk drive
Capabilities: 16
HardwareID: System.String[]
CompatibleIDs: System.String[]
ContainerID: {2471d8a3-e22c-5a5e-8b09-f0bb7616119d}
ConfigFlags: 0
ClassGUID: {4d36e967-e325-11ce-bfc1-08002be10318}
Driver: {4d36e967-e325-11ce-bfc1-08002be10318}\0010
Class: DiskDrive
Mfg: @disk.inf,%genmanufacturer%;(Standard disk drives)
Service: disk
FriendlyName: SanDisk Cruzer USB Device
 
But when I export this registry entry to a text file, I get the following results:
 
Obviously we see much more information in the exported data. Why is there so much more info here and how can I get my VB program to access this information?
 
I am trying to write some code to obtain USB Usage History.
 
Thanks for any help,
 
Key Name:          HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Enum\USBSTOR\Disk&Ven_SanDisk&Prod_Cruzer&Rev_1100
Class Name:        <NO CLASS>
Last Write Time:   1/17/2013 - 2:51 PM
 
Key Name:          HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Enum\USBSTOR\Disk&Ven_SanDisk&Prod_Cruzer&Rev_1100\SDXX1005181106121551&0
Class Name:        <NO CLASS>
Last Write Time:   1/17/2013 - 2:51 PM
Value 0
  Name:            DeviceDesc
  Type:            REG_SZ
  Data:            @disk.inf,%disk_devdesc%;Disk drive
 
Value 1
  Name:            Capabilities
  Type:            REG_DWORD
  Data:            0x10
 
Value 2
  Name:            HardwareID
  Type:            REG_MULTI_SZ
  Data:            USBSTOR\DiskSanDisk_Cruzer__________1100
                   USBSTOR\DiskSanDisk_Cruzer__________
                   USBSTOR\DiskSanDisk_
                   USBSTOR\SanDisk_Cruzer__________1
                   SanDisk_Cruzer__________1
                   USBSTOR\GenDisk
                   GenDisk
 
Value 3
  Name:            CompatibleIDs
  Type:            REG_MULTI_SZ
  Data:            USBSTOR\Disk
                   USBSTOR\RAW
 
Value 4
  Name:            ContainerID
  Type:            REG_SZ
  Data:            {2471d8a3-e22c-5a5e-8b09-f0bb7616119d}
 
Value 5
  Name:            ConfigFlags
  Type:            REG_DWORD
  Data:            0
 
Value 6
  Name:            ClassGUID
  Type:            REG_SZ
  Data:            {4d36e967-e325-11ce-bfc1-08002be10318}
 
Value 7
  Name:            Driver
  Type:            REG_SZ
  Data:            {4d36e967-e325-11ce-bfc1-08002be10318}\0010
 
Value 8
  Name:            Class
  Type:            REG_SZ
  Data:            DiskDrive
 
Value 9
  Name:            Mfg
  Type:            REG_SZ
  Data:            @disk.inf,%genmanufacturer%;(Standard disk drives)
 
Value 10
  Name:            Service
  Type:            REG_SZ
  Data:            disk
 
Value 11
  Name:            FriendlyName
  Type:            REG_SZ
  Data:            SanDisk Cruzer USB Device
 

Key Name:          HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Enum\USBSTOR\Disk&Ven_SanDisk&Prod_Cruzer&Rev_1100\SDXX1005181106121551&0\Device Parameters
Class Name:        <NO CLASS>
Last Write Time:   1/17/2013 - 2:51 PM
 
Key Name:          HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Enum\USBSTOR\Disk&Ven_SanDisk&Prod_Cruzer&Rev_1100\SDXX1005181106121551&0\Device Parameters\MediaChangeNotification
Class Name:        <NO CLASS>
Last Write Time:   9/5/2011 - 8:07 PM
 
Key Name:          HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Enum\USBSTOR\Disk&Ven_SanDisk&Prod_Cruzer&Rev_1100\SDXX1005181106121551&0\Device Parameters\Partmgr
Class Name:        <NO CLASS>
Last Write Time:   9/5/2011 - 8:07 PM
Value 0
  Name:            Attributes
  Type:            REG_DWORD
  Data:            0
 
Value 1
  Name:            DiskId
  Type:            REG_SZ
  Data:            {00af4242-d76c-11e0-8169-0024e8e34876}
 

Key Name:          HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Enum\USBSTOR\Disk&Ven_SanDisk&Prod_Cruzer&Rev_1100\SDXX1005181106121551&0\LogConf
Class Name:        <NO CLASS>
Last Write Time:   1/17/2013 - 2:51 PM

AnswerRe: Decoding USBSTOR Registry Entry in VBmemberChandraRam17 Jan '13 - 20:03 
Looks like you are only reading one level down - your sub-key has further sub-keys.
 
Suggestion - use recursion to get at all the info.
 
HTH
Happiness will never come to those who fail to appreciate what they already have. -Anon

AnswerRe: Decoding USBSTOR Registry Entry in VBmemberAlan N18 Jan '13 - 1:21 
Your code is essentially correct but what you haven't done is to read the type of data stored in each name-value pair so that the correct cast can be applied.
 
The raw data obtained from GetValue(valueName) is typed as Object and the ToString() conversion gives a correct representation in most cases, the exceptions being when the actual type is an array (REG_BINARY, REG_MULTI_SZ)
 
The technique is read the type via GetValueKind(valueName) and then apply a cast to the Object returned from GetValue(valueName). The incomplete method below shows the basics and in your case formatting the values ready for display should be done in the gaps left as "do something appropriate".
 
Private Sub InterpretValue(rawValue as Object, interpretAsType as RegistryValueKind)
    Select Case interpretAsType
        Case RegistryValueKind.Binary
          ' REG_BINARY
            Dim byteArray As Byte() = DirectCast(rawValue, Byte())
            ' Do something appropriate
            Exit Select
        Case RegistryValueKind.DWord
          ' REG_DWORD
            Dim signedValue32 As Integer = DirectCast(rawValue, Integer)
            ' Do something appropriate
            Exit Select
        Case RegistryValueKind.QWord
          ' REG_QWORD
            Dim signedValue64 As Long = DirectCast(rawValue, Long)
            ' Do something appropriate
            Exit Select
        Case RegistryValueKind.Unknown, RegistryValueKind.String, RegistryValueKind.ExpandString
            Dim stringValue as String = rawValue.ToString()
            ' Do something appropriate
            Exit Select
        Case RegistryValueKind.MultiString
          ' REG_MULTI_SZ
            Dim stringArray As String() = TryCast(rawValue, String())
            ' Do something appropriate
            Exit Select
    End Select
End Sub

GeneralRe: Decoding USBSTOR Registry Entry in VBmemberSantLou4018 Jan '13 - 1:47 
Thanks for the explanations. I understand that I should be considering the data type. I can change my code accordingly. But what about the "Last Write Time" information that is displayed in the exported text data for these keys? How can I access that? My goal is to capture the History of each USB device that was used in the system, with dates and times. I'm assuming that the Last Write Time on the exported text will give me this information, but I don't see how my code, even with the data type considerations, will access that.
 
Thanks,
GeneralRe: Decoding USBSTOR Registry Entry in VBmemberAlan N18 Jan '13 - 4:05 
The .NET RegistryKey exposes a small subset of the full Windows Registry API and to get the LastWriteTime requires the Windows RegQueryInfoKey function. Microsoft made this really difficult prior to .NET 4, as the RegistryKey class did not expose the operating system registry key handle.
 
With the restriction of .NET 4 it should be a simple matter of using P/Invoke to call RegQueryInfoKey with the twelve parameters set correctly! I haven't done this but most of them are optional, so can probably be set to null or IntPtr.Zero.
 
http://msdn.microsoft.com/en-us/library/windows/desktop/ms724902(v=vs.85).aspx[^]
 
Retrieving the LastWrite time from a Registry key[^]
 
http://www.pinvoke.net/default.aspx/advapi32/RegQueryInfoKey.html[^]
 
http://msdn.microsoft.com/en-us/library/microsoft.win32.registrykey.handle.aspx[^]
 
If you have to work on a lower (lesser?) version of .NET then I don't think this will be an easy task as there is no facility to exchange handles between the .NET RegistryKey class and the native Windows functions. I think the only option would be using RegOpenKeyEx to get the handle and then call RegQueryInfoKey.
JokeRe: Decoding USBSTOR Registry Entry in VBmemberJeffnogueira22 Jan '13 - 4:31 
Wink | ;)
QuestionVB.NET ReportViewer too many Page Breaks renderedmemberSantLou4017 Jan '13 - 3:39 
Hi All,
 
I developed my app using VS 2012.
 
I designed my report using the Report Viewer control. The data on my report is not tabular. It is a fixed-field form that spans several pages. I set the data source to a collection of an object that I developed and all the data for the report comes from my collection (which will always only have one item in it).
 
The report seems to be working fine, I setup a header and footer. When my code refreshes the report, my data is displayed nicely on the report as i designed it. However, when I convert to Print view, the report seems to be inserting page breaks while rendering. my nice little 4-page form becomes a 10 page report with page breaks occurring on every other page and some extra at the end.
 
What can I look at to determine why these extra page breaks occur in the rendering process? I thought it may be page layout related, so I changed the margins to all zeros and still see the additional page breaks.
 
Also, another thing I noticed is that when I added the footer, the footer height is about 2.5 inches and the designer will not allow me to change it.
 
Any help will be greatly appreciated.
 
Thanks,
AnswerRe: VB.NET ReportViewer too many Page Breaks renderedmemberChandraRam17 Jan '13 - 20:04 
What are the printer parameters? The printer selected, page size and margins will determine how many pages are rendered...
 
HTH
Happiness will never come to those who fail to appreciate what they already have. -Anon

GeneralRe: VB.NET ReportViewer too many Page Breaks renderedmemberSantLou4018 Jan '13 - 1:39 
Hi ChandraRam,
 
Thanks for your quick reply. My page size is 8.5x11. Page Units = Inches. Orientation in Portrait. I originally had the margins set at .5 for all, but I also tried changing them all to 0 with no change in the resulting number of pages.
 
In designing my report I used the Report Ruler to ensure that my data is only setup between 1 inch on the left and 7inch on the right. I used a Rectangle control to contain the different sections of my form so I can insure that each rectangle is only 6 inches long, starting at 1 inch on the right and all my field data is contained within a rectangle control. I am currently not specifying page breaks in the properties of any of my rectangle controls, although I did try to add a page break property on some rectangles which did not affect the additional page breaks when printing.
 
So my issue now is how can I determine what is specifically causing a page break.
Questioncontrol 5 appliances using pc's parallel port[vb.net 2010]memberLord Christian15 Jan '13 - 20:10 
my pc's operating system
windows 7 ultimate 32 bit
-------------------------
 

i am working on a project that will control 5 devices through pc parallel port/printer port.
when i run the program it will first appear a loginform
then when i enter.
it always returns that the port doesnt exist.
even though i have the port it cant detect it.. i dont know what is wrong with my code.
 
--------------------------------------------------------
Dim FILE_NAME As String = "LPT1"
 
If System.IO.File.Exists(FILE_NAME) Then
Dim objWriter As New System.IO.StreamWriter(FILE_NAME)
objWriter.Write("hi")
objWriter.Close()
MsgBox("ok")
Else
MsgBox("port does not exist")
End If
------------------------------------------------------
then after the login the next form is homepage. there you'll see the switch buttons that will turn on and off a device. when i clicked any of this buttons an error will prompt. its say that object reference not set to an instance of an object
 
NullReferenceException was unhandled.
 
Private Sub btn_app1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_app1.Click
If btn_app1.Text = "ON" Then
btn_app1.Text = "OFF"
btn_app1.BackColor = Color.Red
io(0)
Else
btn_app1.Text = "ON"
btn_app1.BackColor = Color.Green
io(1)
End If
End Sub
 
Private Sub btn_app2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_app2.Click
If btn_app2.Text = "ON" Then
btn_app2.Text = "OFF"
btn_app2.BackColor = Color.Red
io(0)
Else
btn_app2.Text = "ON"
btn_app2.BackColor = Color.Green
io(2)
End If
End Sub
 
Private Sub btn_app3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_app3.Click
If btn_app3.Text = "ON" Then
btn_app3.Text = "OFF"
btn_app3.BackColor = Color.Red
io(0)
Else
btn_app3.Text = "ON"
btn_app3.BackColor = Color.Green
io(4)
End If
End Sub
 
Private Sub btn_app4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_app4.Click
If btn_app4.Text = "ON" Then
btn_app4.Text = "OFF"
btn_app4.BackColor = Color.Red
io(0)
Else
btn_app4.Text = "ON"
btn_app4.BackColor = Color.Green
io(8)
End If
End Sub
 
Private Sub btn_app5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_app5.Click
If btn_app5.Text = "ON" Then
btn_app5.Text = "OFF"
btn_app5.BackColor = Color.Red
io(0)
Else
btn_app5.Text = "ON"
btn_app5.BackColor = Color.Green
io(16)
End If
End Sub
 
Private Sub io(ByVal bit As Integer)
val = axHwinterface1.InPort(888)
axHwinterface1.OutPort(888, CShort(val Or bit))
End Sub
 
--------------------------------------------------------
please help me im new in this.. Cry | :(( i need your help guys.. thank you in advance..
every response is very much appreciated
 
if you want to see my whole project you can Download it here
 
http://www.mediafire.com/?1zvx1ty736r2nnb
AnswerRe: control 5 appliances using pc's parallel port[vb.net 2010]memberBernhard Hiller15 Jan '13 - 20:42 
There is an important and great technology: it's called debugging.
Set a break point somewhere in your code, e.g at Private Sub btn_app1_Click(...) and then run the code step by step. Thus you will detect the line of code where the exception is thrown.
I guess it happens at Private Sub io(...). Either axHwinterface1 is Nothing, or InPort(888) returns Nothing, then the next line fails.
Debugging will tell you the exact reason.

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


Advertise | Privacy | Mobile
Web03 | 2.6.130523.1 | Last Updated 21 May 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid