So im making a app and theres a problem as always
Form 2 _

Private Sub CustmBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CustmBtn.Click
        Dim IconLoc As String
        Dim CustmIcon As New OpenFileDialog
        CustmIcon.AutoUpgradeEnabled = True
        CustmIcon.DereferenceLinks = True
        CustmIcon.SupportMultiDottedExtensions = True
        CustmIcon.Filter = "Windows Based Icons|*.ico"
        If CustmIcon.FileName = "" Then
            IconLoc = CustmIcon.FileName
            My.Settings.My_OpeniconLocation_String = IconLoc
            '    MainForm.Icon = New System.Drawing.Icon(CustmIcon.FileName)
        End If
    End Sub

Now For MainForm _

If My.Computer.FileSystem.FileExists(System.Environment.CurrentDirectory & "\MoonBase Project Setup.exe") Then
            My.Computer.FileSystem.DeleteFile(System.Environment.CurrentDirectory & "\MoonBase Project Setup.exe")
        End If
            If My.Settings.My_TabPageNameFirst = Nothing Then
                Me.TabPageRich1.Text = My.Settings.My_TabPageNameFirst
                Me.TabPageRich2.Text = My.Settings.My_TabPageNameSecond
                Me.TabPageRich3.Text = My.Settings.My_TabPageNameThrid
                Me.TabPageRich4.Text = My.Settings.My_TabPageNameThrid
            End If
            Call PictureBoxFucntions()
            Call NotesViewrRichtextctrlFucntions()
            Call TabPagesRichBoxFucntions()
            Dim Max As System.Drawing.Size = New System.Drawing.Size(522, 593)
            Me.MaximumSize = Max
            OptionsForm.MainFormTopmostCKB.Checked = My.Settings.My_Topmost_app
            If OptionsForm.MainFormTopmostCKB.Checked Then
                Me.TopMost = True
                Me.TopMost = False
            End If

            If My.Settings.My_First_Build = True Then
                Me.Icon = Nothing
                    Me.Text = My.Settings.My_Main_Caption
                    If My.Settings.My_OpeniconLocation_String = vbEmpty Then <<<<<<<<< Heres the problem
                        ' Me.Icon = Nothing
                        Me.Icon = New Icon(System.Drawing.Icon(My.Settings.My_OpeniconLocation_String)          
                    End If  <<<<<<<<<<<<<<<<<<<<<<<<<<
                Catch eee As Exception
                    My.Settings.My_First_Build = True
                End Try
            End If
            '     My.Settings.My_First_Build = False
            '     If My.Settings.My_First_Build = False Then
            '     My.Settings.Reload()  
        Catch WathDebuggingProcess As Exception
        End Try

The Problem is with loading the custom icon
Doesnt seem to get the Location of the sring in my.setting.My_OpeniconLocation_String
I dont know what im doing wrong here??:?:

Recommended Answers

All 18 Replies

Member Avatar

You will have to reload the settings after you have saved them (My.Settings.Reload). Print out the value before and after to make sure that the value is what you need it to be.

Just for clarification: Are you using the settings just to pass data between forms? That is probably the worst idea I have ever heard. If you want to pass data, consider using a class instead.

:icon_neutral:Enlighten me please

And by the way im a Begginer:zzz:

Jip ive triple checked still doesnt work

Member Avatar

Before we begin: What are you trying to accomplish exactly?

:DJust to load custom icon or orginal thts all

Member Avatar

Ok. And why is the code to select an icon in a seperate form (Form_2)?

BEcuase its part of Settings Form 2 = Settings
i dont really want to go in my app its personal
Im like tht sory for not explaining tht form2 was settings Form2

Member Avatar

Ok, no problem.
Settings are normally used to store user/application specific data and not as temporary objects to pass data between forms.
You should read up on overloading the ShowDialog() method of forms and how to pass classes to forms, like this. That is one of many ways how to effectively pass data without using global variables.

So amm about my problem how does manage to store loc of Icon and get it on next load using my.settings

Amm i dont really understand so sum iformation may not be saved but they are , but they are not seen becuase of the metods of overloading what im doing and thus doesnt get allowed becuase form cant read data:idea:

Wiat n minute dude im not trying to store the physical object im just trying to save the location as string and then it gets load up by Form1 if There's a Loc ofcourse but im trying to store the object just the text to load as string

Member Avatar

I have absolutely no idea what you just said. Can you rewrite that in proper English, please?

Ok in clear English all im trying to accomplish is to store the text of Filedialog.filename as string and then gets load up by form 1 code and that then Gets the string in my.settings im not trying to store tempry object

Member Avatar

But you are trying to use My.Settings as a mean to store the location of the icon in Form2, then trying to read it in your main form! That doesn't work, does it? Have you tried debugging? What do the values read? You need to put in some effort to sovle your problem, I can't do all the work for you.

It does give errors at all so please tel me how to debug there's a window tht doesnt appear in Error List I would like to know where it is

SOry it doesnt give error at all

Im still not getting ir right can someone please help me

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.