Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Empfohlene Antworten

Veröffentlicht

Hallo,

Ich möchte eine Userform in Vb für Excel erstellen, die wie eine Inputbox funktioniert. Es sollen 2 Sachen eingegeben werden und diese Eingabe soll jeweils eine Variable zugeordnet bekommen, welche ich dann in einem anderen Makro verwenden kann.

Mein Problem:

Ich hab einfach zwei Textfelder genommen und in den Code für die Userform die variablenzuordnung gemacht.

X= userform.text1

Im Code der Userform kann ich dann auch:

Msgbox x

schreiben und bekomm den eingegebenen Wert per Msgbox ausgegeben.

Wenn der Hauptcode der die Userform öffnent aber weiterläuft, und ich in dem die Msgbox verwenden will, kann ich die variable nicht verwenden.

Hat einer ne Idee?

Sub Test1()

U1.Show

Dim x1 As Variant

Dim x2 As Variant

MsgBox "Text1 lautet " & x1 & " und Text2 lautet " & x2

End Sub

Und in der UserForm U1 steht:

Sub Userform1()

End Sub

Private Sub cmd_Click()

U1.Hide

x1 = U1.TextBox1

x2 = U1.TextBox2

MsgBox x1 & " " & x2

End Sub

Vielleicht ein Deklarationsproblem, aus der Hilfe:

"Auf Variablen, die mit der Public-Anweisung deklariert wurden, kann von allen Prozeduren in allen Modulen aus allen Anwendungen zugegriffen werden."

Es gibt also: Private-, Public - oder Dim-Anweisung

Gruss

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.