Results 1 to 23 of 23

Thread: [2008] Few Basic Questions

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2008
    Posts
    10

    [2008] Few Basic Questions

    Alright, I've searched the web for a while now but I can't seem to find information to these questions:

    1) Does one form house all the tools and hide/show them when needed or do I call up other forms when needed?

    2) Can't find a good tutorial on VB databases

    3) Lastly, how could I read information from a .txt file and when displayed on the form somehow place pictures within the text at designated points. (Basically making a walkthrough with pictures to demonstrate)

    Thanks in advance.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: [2008] Few Basic Questions

    1. That depends entirely on what you have for controls, how many there are, and for what they are being used. Your up front program design will dicate how many forms you will be using.
    2. Go through our Database FAQ section.
    3. You can display pictures in a richtextbox after reading a text file into it. However, if you save the richtextbox back to a text file, all graphics will be lost.

  3. #3
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [2008] Few Basic Questions

    1. A form will control/house all the controls you place on it. If you dont add any controls to it then it will have none.

    2. DB Forum FAQ link - http://www.vbforums.com/showthread.php?t=337051

    3. Not sure on what you really are trying to do but you could use a picturebox control and a label control to load the data into. What kind of layout/design are you looking for?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  4. #4

    Thread Starter
    New Member
    Join Date
    Jul 2008
    Posts
    10

    Re: [2008] Few Basic Questions

    Thank you for answering the first two, for the third I think it may just be easier to load an .html file for the guide instead of making it from a text file.

    However I uncovered one more question.

    First, currently I'm using this code to switch between forms

    Code:
    Private Sub idb_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles idb.Click
            itemdb.Show()
            Me.Hide()
        End Sub
    The question with this is a) is it good protocol and b) can you close a form without closing the program?

    Thanks for your help so far.

  5. #5
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [2008] Few Basic Questions

    Using .Hide wil not close the form but only hide it from display which will keep a program open still if that form is your startup object.

    If your form is not going to be used again then .Close it is best so it frees up the resources.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  6. #6

    Thread Starter
    New Member
    Join Date
    Jul 2008
    Posts
    10

    Re: [2008] Few Basic Questions

    Now the problem I'm having is that I want the web browser control in the form to load a webpage on the harddrive. However seeing as I want thsi to work on multiple computers I can put an absolute address in there. But as far as ive tried, I cant get a relative address to work. Any suggestions?

  7. #7
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [2008] Few Basic Questions

    Are you using Application.StartupPath prepended with your html file name?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  8. #8

    Thread Starter
    New Member
    Join Date
    Jul 2008
    Posts
    10

    Re: [2008] Few Basic Questions

    I googled that and I think I figured out how to do what you were asking,

    Code:
    Dim value As String
            value = Application.StartupPath
            Me.WebBrowser1.Navigate(value + "qlistm.html")
    However in debug it doesnt work and (for now) im not sure if it prepended it correctly.

  9. #9
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [2008] Few Basic Questions

    When working in the IDE your startuppath will be the location of your build. Usually in your projects "bin\Debug" directory. Verify that you have your html file in that directory
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  10. #10

    Thread Starter
    New Member
    Join Date
    Jul 2008
    Posts
    10

    Re: [2008] Few Basic Questions

    Thanks alot for thhe information so far! For now it will work, however what directory should the file be in for when I publish it?

    Back to databases, I still can't work them the way I want, that is, having it display one item from x column at a time in a text box. So far I have this, but it's more me trying to frankenstein something together then actually knowing what it does.

    Code:
    Dim ds As DataSet
            Dim strSQL As String = "SELECT [Name], [Location], [Price], [Quest Item] FROM [Items]"
            Me.ItemsTableAdapter.Fill(Me.Database1DataSet1.Items)
            name1.Text = Me.Database1DataSet1.Items.Tables(0).Rows(0).Item("Name").ToString()
    New question: Can BASIC search strings and remove portions of them like c++? (Im looking to make a html parser)

  11. #11
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [2008] Few Basic Questions

    The file would be in the same directory as the exe. The exe is the "Application" so when you access its .StartupPath" property it will be the full path to where the exe resides.

    If you wanted you could contain the file in a subdirectory for a cleaner isolated look but it would be for looks only.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  12. #12

    Thread Starter
    New Member
    Join Date
    Jul 2008
    Posts
    10

    Re: [2008] Few Basic Questions

    With a windows forms application I dont see an .exe when I publish it, just a autorun, setup, and application manifest, and in teh fodler created in Program Files, a application refrence.

  13. #13
    Hyperactive Member
    Join Date
    Jun 2008
    Location
    Nowhere
    Posts
    427

    Re: [2008] Few Basic Questions

    you dont publish if you want an exe, you build
    "Programming is like sex. One mistake and you have to support it for the rest of your life." ~Michael Sinz


    Code Snippets/Usefull Links:
    WinRAR DLL|Vista Style Form|Krypton Component Library|Windows Form Aero|Parsing XML files|Calculate File's CRC 32|Download a list of files.

  14. #14
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [2008] Few Basic Questions

    Oh you are using Express. I dont use it much at all lol. Use the Build menu to compile the exe and then you will need to decide on how you want to distribute it by Publishing it or using ClickOnce to build an instalation package.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  15. #15
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2008] Few Basic Questions

    Quote Originally Posted by RobDog888
    Publishing it or using ClickOnce to build an instalation package.
    Publishing does build a ClickOnce installation package.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  16. #16

    Thread Starter
    New Member
    Join Date
    Jul 2008
    Posts
    10

    Re: [2008] Few Basic Questions

    Oi, I found an .exe file in bin\debug but it open in VB by default so im guessing thats not it?

    EDIT: Didn't find an .exe but I found an application that seems to work.
    Last edited by Tenedy; Jul 8th, 2008 at 09:33 PM.

  17. #17

    Thread Starter
    New Member
    Join Date
    Jul 2008
    Posts
    10

    Re: [2008] Few Basic Questions

    One problem I've noticed though, is that when I open up a different form and hide the main one, and then close that different form, it doesn't show the main form or close the program. Any suggestions?

  18. #18
    Addicted Member
    Join Date
    Nov 2006
    Location
    Minnesota
    Posts
    235

    Re: [2008] Few Basic Questions

    Let's say you have 2 forms: frmOne and frmTwo. frmOne is the main form.

    On frmOne there is a button: btnShowTwo.

    frmOne:
    vb Code:
    1. Private Sub btnShowTwo_Click(ByVal sender As object, ByVal e As System.EventArgs) Handles btnShowTwo.Click
    2.      Dim frmShowTwo as new frmTwo(Me)
    3.      frmShowTwo.Show()
    4.      Me.Hide()
    5.  
    6. End Sub

    Now on frmTwo we need to tell it that when it is closing it needs to reShow the main form.

    frmTwo:
    vb Code:
    1. Dim OriginalForm as Form
    2.  
    3. Public Sub New(ByVal CallingForm As Form)
    4.      MyBase.New
    5.      InitializeComponent()
    6.     OrginalForm = CallingForm
    7. End Sub
    8.  
    9. Private Sub frmTwo_FormClosing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs)
    10.      'this will close the frmTwo object
    11.      OriginalForm.Show()
    12. End Sub
    If someone has helped you, please make sure to rate them.

  19. #19
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2008] Few Basic Questions

    Just call ShowDialog instead of Show:
    vb.net Code:
    1. Me.Hide()
    2. SomeForm.ShowDialog()
    3. Me.Show()
    Tada! ShowDialog doesn't return until the form is dismissed so you can simply show the caller again immediately
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  20. #20

    Thread Starter
    New Member
    Join Date
    Jul 2008
    Posts
    10

    Re: [2008] Few Basic Questions

    Alrighty, thanks.

    However I'm still having the hardest time finding something on databases. Using MSDN tutorials I got some tool in there but it wasn't really what I wanted.

    Basically I just want to take info from the database and place it into a textbox.

    Also, I'm using a .sdf database, most other tutorials I've come across seem to use .dbm

  21. #21
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2008] Few Basic Questions

    Which database you're using is pretty much irrelevant. ADO.NET code all follows the same pattern. If you're using a different database then you simply change the connection string and, perhaps, the data namespace. Follow the Data Access link in my signature for some ADO.NET code examples. As that thread says, if you're using Access you can just change SqlClient to OleDb. If you're using SQL Server CE then you just switch SqlClient to SqlServerCe.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  22. #22

    Thread Starter
    New Member
    Join Date
    Jul 2008
    Posts
    10

    Re: [2008] Few Basic Questions

    I seem to run into trouble at this line:

    Code:
    Dim connection As New System.Data.SqlServerCe.SqlCeConnection("Microsoft.SQLSERVER.MOBILE.OLEDB.3.0;Data Source=C:\Users\Blake\Documents\Visual Studio 2008\Projects\Ori\Ori\Database1.sdf")
    Code as a whole:

    Code:
    Dim connection As New System.Data.SqlServerCe.SqlCeConnection("Microsoft.SQLSERVER.MOBILE.OLEDB.3.0;Data Source=C:\Users\Blake\Documents\Visual Studio 2008\Projects\Ori\Ori\Database1.sdf")
            Dim command As New System.Data.SqlServerCe.SqlCeCommand("SELECT Price, Quest Item, Name FROM Items", connection)
            connection.Open()
            Dim reader As System.Data.SqlServerCe.SqlCeDataReader = command.ExecuteReader()
            While reader.Read()
                MessageBox.Show(String.Format("There are {0} {1} of {2} remaining in stock.", _
                                      reader("Quantity"), _
                                      reader("Unit"), _
                                      reader("Name")))
            End While
            reader.Close()
            connection.Close()

  23. #23
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2008] Few Basic Questions

    That's not a valid connection string. First up, you're trying to create a SqlCeConnection with a connection string for an OleDbConnection. Secondly, that connection string would not be valid even for an OleDbConnection string because it's not complete. Go to www.connectionstrings.com and read the SSCE page carefully.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width